{ "info": { "author": "Troy Melhase", "author_email": "troy@troy.io", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "Object Counters for Django\n==========================\n\nThis is a simple app for associating named integer values with\narbitrary Django model objects.\n\nUsing counters allows you to keep scalar values out of your models.\nInstead of this:\n\n class Person(models.Model):\n name = models.CharField(...)\n number_of_friends_total = models.IntegerField(...)\n number_of_friends_recent = models.IntegerField(...)\n number_of_friends_last_month = models.IntegerField(...)\n\nYou can do this:\n\n capt = Person.objects.get(name='Jean-Luc Picard')\n Counter.objects.create_for_object('friends_total', capt, 1014)\n\nAnd:\n\n last = Counter.objects.get_for_object('friends_last_month', capt)\n last.value += -3 # lost the away team.\n last.save()\n\nThe approach of reading and writing values in a separate model allows\nyou to evolve some of your data without touching the models. And it\nkeeps your models a bit more tidy.\n\nInstall\n-------\n\nPull down the app:\n\n $ pip install django-objectcounters\n\nAdd it to your `INSTALLED_APPS`:\n\n INSTALLED_APPS = (\n ...\n 'objectcounters'\n )\n\nSync your database:\n\n $ ./manage.py syncdb --migrate\n\nTo run the sample app, make sure you've got generic admin installed globally\n(ugh), or better yet, create a new virtual env and install it there with the\nsample.\n\n\nPython Usage\n-------------\n\nThe `Counter` model is a regular Django model, so you can create, read, update\nand delete records in the usual way. Additionally, the model provides a manager\nwith a few more methods:\n\n1. `Counter.get_for_object(name, instance, **kwargs)`\n\nUse this method to get an existing counter for an object. Pass in the name of\nthe counter, like 'total-holodeck-hours', and a model instance. Keyword\narguments are passed thru to the `get()` call.\n\n2. `Counter.get_value_for_object(self, name, instance, default=0, **kwargs)`\n\nUse this method when you need just the value of a counter and not the counter\nrecord. Keyword arguments are passed thru to the `get()` call.\n\n3. `Counter.create_for_object(self, name, instance, value=0)`\n\nThis is just like Django's `get_or_create` and returns the same kind of\ntwo-tuple. Use this when you need to get a counter and create it if necessary\nin one step.\n\n\n\nTemplate Usage\n--------------\n\nYou can also enable counters inside of templates pretty easily.\n\nIn your templates, load the tag:\n\n `{% load counter_tags %}`\n\nThen you can render values like this:\n\n \n {% counter_for_object \"monthly_shack_visits\" user as visits %}\n I went to Shake Shack {{ visits }} times this month.`\n ", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/natural/django-objectcounters", "keywords": null, "license": "BSD License", "maintainer": null, "maintainer_email": null, "name": "django-objectcounters", "package_url": "https://pypi.org/project/django-objectcounters/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-objectcounters/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/natural/django-objectcounters" }, "release_url": "https://pypi.org/project/django-objectcounters/0.1/", "requires_dist": null, "requires_python": null, "summary": "Associate counters with Django model records.", "version": "0.1" }, "last_serial": 674797, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "9b0e24f1e6673f2cde711fac891b929a", "sha256": "15d9a0375bdb3ec02e9699bb80f2ae9c70ccb6fc786d361ab43b401065bc195d" }, "downloads": -1, "filename": "django-objectcounters-0.1.tar.gz", "has_sig": false, "md5_digest": "9b0e24f1e6673f2cde711fac891b929a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3704, "upload_time": "2013-05-21T18:58:22", "url": "https://files.pythonhosted.org/packages/e6/73/6f38d4cbe3dda83542d246a68f342cf8a61db6ecc4066e0786ab77d77ff5/django-objectcounters-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9b0e24f1e6673f2cde711fac891b929a", "sha256": "15d9a0375bdb3ec02e9699bb80f2ae9c70ccb6fc786d361ab43b401065bc195d" }, "downloads": -1, "filename": "django-objectcounters-0.1.tar.gz", "has_sig": false, "md5_digest": "9b0e24f1e6673f2cde711fac891b929a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3704, "upload_time": "2013-05-21T18:58:22", "url": "https://files.pythonhosted.org/packages/e6/73/6f38d4cbe3dda83542d246a68f342cf8a61db6ecc4066e0786ab77d77ff5/django-objectcounters-0.1.tar.gz" } ] }