{ "info": { "author": "Daniel Greenfeld", "author_email": "pydanny@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 7 - Inactive", "Environment :: Web Environment", "Framework :: Django", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "===================\r\ndjango-profiletools\r\n===================\r\n\r\nFeatures\r\n========\r\n\r\n* Lazy loading of your authenticated `profile` record across the `request` object lifetime. That means in the Python code and the templates.\r\n* Name your profile model anything you want in `settings.AUTH_PROFILE_MODULE`.\r\n\r\nInstallation\r\n============\r\n\r\nGet the code::\r\n\r\n pip install django-profiletools\r\n\r\nInstall the middleware and context_processor in your settings.py::\r\n\r\n TEMPLATE_CONTEXT_PROCESSORS = (\r\n ...\r\n 'profiletools.context_processors.fetch_profile',\r\n )\r\n\r\n MIDDLEWARE_CLASSES = (\r\n ...\r\n 'profiletools.middleware.LazyProfileMiddleware',\r\n )\r\n\r\nAlso in settings.py, set the AUTH_PROFILE_MODULE to your profile model::\r\n\r\n AUTH_PROFILE_MODULE = \"profiles.Profile\"\r\n\r\nBased on that, your profile model should resemble something like::\r\n\r\n # profiles.models.Profile.py\r\n from django.contrib.auth.models import User\r\n from django.db import models\r\n\r\n class Profile(models.Model):\r\n\r\n user = models.OneToOneField(User)\r\n \r\n def __unicode__(self):\r\n return self.user.username\r\n\r\n**note:** If you don't use ``profiles.models.Profile``, say ``members.models.UserProfile`` go ahead and change the ``AUTH_PROFILE_MODULE`` to \"members.UserProfile\".\r\n\r\nBasic Usage\r\n============\r\n\r\nIn your templates::\r\n\r\n {{ request.my_profile }}\r\n\r\nIn your functional views::\r\n\r\n profile = request.my_profile\r\n\r\nIn your class-based views::\r\n\r\n profile = self.request.my_profile\r\n\r\nCall my_profile as many times as you want, it only loads once. So if you call it 100 times in a view, the ``SQL SELECT`` is only done the first time. If no user is found then the my_profile call result is ``None``, which makes it easier to handle templates which need to be able to handle unauthenticated users (like the `about` page).\r\n\r\n**note:** If you are using the ``members.UserProfile`` example, you'll need to call that by using ``request.my_userprofile``.\r\n\r\nProblems with Python's \"**is**\" evaluation and \"**type**\" built-in\r\n==================================================================\r\n\r\nIf you use the **is** evaluation before doing anything else with the my_profile object, it will behave in a slightly unexpected manner:\r\n\r\nThe **will always return false**. For example::\r\n\r\n >>> print(request.my_profile is None)\r\n False\r\n >>> p = request.user.get_profile()\r\n >>> print(request.my_profile is p)\r\n False\r\n \r\n \r\nAlso, the **type** built-in will return a ``django.utils.functional.SimpleLazyObject`` object::\r\n\r\n >>> print(type)\r\n \r\n\r\nKeep in mind what is placed in the ``my_profile`` value is not a ``ModelClass``\r\ninstance or ``None`` object, but rather a ``django.utils.functional.SimpleLazyObject``.\r\n\r\n**How to evaluate the my_profile object**\r\n\r\nUse ``==`` to evaluate the my_profile object. This forces the object to be evaluated\r\nand won't return frustrating false-positives.\r\n\r\nInspiration\r\n===========\r\n\r\nThe lazy loading of profiles was inspired by the rather incredible Noah Kantrowitz.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/pydanny/django-profiletools", "keywords": "django,profiles", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "django-profiletools", "package_url": "https://pypi.org/project/django-profiletools/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-profiletools/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/pydanny/django-profiletools" }, "release_url": "https://pypi.org/project/django-profiletools/0.2.1/", "requires_dist": null, "requires_python": null, "summary": "Tools for Profile models in Django.", "version": "0.2.1" }, "last_serial": 768424, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "f9f262df38884a1371a088231e196f22", "sha256": "e758adbff838157e369bf7eab1000ba0f641256b48d23869009673ffb49cf03f" }, "downloads": -1, "filename": "django-profiletools-0.1.tar.gz", "has_sig": false, "md5_digest": "f9f262df38884a1371a088231e196f22", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11540, "upload_time": "2012-08-09T15:55:15", "url": "https://files.pythonhosted.org/packages/e3/e4/bf03653b23f5ed708be89b3fc0d55e34c4de01a479f9c52eaf14b5ae119d/django-profiletools-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "274f6829804e00cee7ff4742cb508c3d", "sha256": "e1b1d4409b8ed4e522e25477496334f6cd0d44f42324a325c282ecd46562ed28" }, "downloads": -1, "filename": "django-profiletools-0.1.1.tar.gz", "has_sig": false, "md5_digest": "274f6829804e00cee7ff4742cb508c3d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12803, "upload_time": "2012-08-09T23:23:58", "url": "https://files.pythonhosted.org/packages/19/4c/7a0dc6563b338753f9f32e8123ffcf1c701e1e692bcf374dd71f09919aba/django-profiletools-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "3a53a41b15cd1d4c91e7d7586a90df40", "sha256": "65a0dc8e7bde390472d7ecc8e19059a1827b6975fe2fbca76c61224f93c587fc" }, "downloads": -1, "filename": "django-profiletools-0.1.2.tar.gz", "has_sig": false, "md5_digest": "3a53a41b15cd1d4c91e7d7586a90df40", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12840, "upload_time": "2012-08-10T18:30:45", "url": "https://files.pythonhosted.org/packages/dd/f0/20120d562348a62b2f301fa4f596b2d0b3ff04884da20f5e213ec426bddc/django-profiletools-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "5baa59c45c423fd65ab812b0b49bc96f", "sha256": "46094c341700abb40c8e1ed236d2c25034d164c1a638c68baf100f84d666e89c" }, "downloads": -1, "filename": "django-profiletools-0.1.3.tar.gz", "has_sig": false, "md5_digest": "5baa59c45c423fd65ab812b0b49bc96f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13360, "upload_time": "2012-08-15T22:50:13", "url": "https://files.pythonhosted.org/packages/7f/42/c82dcf12ca43e8e6fce8015faf7e4d059614305c0b5d7d611403b5fd9612/django-profiletools-0.1.3.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "72fa6162dc95c97df5c2e433e46ecc9a", "sha256": "5ddda96f689e1ed7e6771dddd3872571eefd93117c23257fc7c648b79de786e9" }, "downloads": -1, "filename": "django-profiletools-0.2.tar.gz", "has_sig": false, "md5_digest": "72fa6162dc95c97df5c2e433e46ecc9a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13648, "upload_time": "2012-08-29T00:54:07", "url": "https://files.pythonhosted.org/packages/64/12/7f4a3d25255162d2d9a3729083cd1e950f24819de9e14a5d77023c77282b/django-profiletools-0.2.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "36a929601b604da813cbb02c774e8d5e", "sha256": "feab1ceff0d2cb1be4ae205a22b404bcf9fd8d6c8ef5fcfc3bf0eefb6e25bba6" }, "downloads": -1, "filename": "django-profiletools-0.2.1.tar.gz", "has_sig": false, "md5_digest": "36a929601b604da813cbb02c774e8d5e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14775, "upload_time": "2012-09-05T19:29:58", "url": "https://files.pythonhosted.org/packages/4e/39/5e0529a6f8a90a3e2aa054094798826636d2fc3cea29fa17d2254ce13a30/django-profiletools-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "36a929601b604da813cbb02c774e8d5e", "sha256": "feab1ceff0d2cb1be4ae205a22b404bcf9fd8d6c8ef5fcfc3bf0eefb6e25bba6" }, "downloads": -1, "filename": "django-profiletools-0.2.1.tar.gz", "has_sig": false, "md5_digest": "36a929601b604da813cbb02c774e8d5e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14775, "upload_time": "2012-09-05T19:29:58", "url": "https://files.pythonhosted.org/packages/4e/39/5e0529a6f8a90a3e2aa054094798826636d2fc3cea29fa17d2254ce13a30/django-profiletools-0.2.1.tar.gz" } ] }