This project provides a base `Profile` model that relates to the built-in `auth.User` model and provides hooks for adding any number of feature extensions. A number of example extensions (address details, avatar, etc) are included.
The basic concept (and some code) is borrowed from the [FeinCMS](https://github.com/feincms/feincms) Page model.
### Usage
To use the profiles module add `profiles` to `INSTALLED_APPS` in your django settings file.
Before proceeding with `manage.py syncdb`, you must add some profile extensions.
The profiles module does not add anything to the User model by default.
### Profile extension modules
Extensions are a way to add often-used functionality the `Profile` model. The
extensions are standard python modules with a `register()` method which will be
called upon registering the extension. The `register()` method receives the
`Profile` class itself and the model admin class `ProfileAdmin` as arguments.
There are two ways to set up the extensions. Either you can use the FeinCMS
approach of registering extensions directly (this should go in your models.py):
from profiles.models import Profile
Profile.register_extensions('title', 'picture', 'address', 'profiles.modules.options.extensions.options')
or you can simply use a setting:
PROFILE_EXTENSIONS = ('title', 'picture', 'address', 'profiles.modules.options.extensions.options')
If the extension requires its own models (like the options extension) then the
app containing the models will also need to be added to your `INSTALLED_APPS`.
### Adding extensions
To add an extension create a python module that defines a register function
which accepts the `Profile` class and the `ProfileAdmin` class as arguments and
modifies them as required.
Here is the address extension (`profiles/extensions/address.py`):
from django.db import models
from django.utils.translation import ugettext_lazy as _
def register(cls, admin_cls):
cls.add_to_class('address1', models.CharField(max_length=255, verbose_name=_('address'), null=True, blank=True))
cls.add_to_class('address2', models.CharField(max_length=255, verbose_name=_('address 2'), null=True, blank=True))
cls.add_to_class('city', models.CharField(max_length=255, verbose_name=_('town/city'), null=True, blank=True))
cls.add_to_class('region', models.CharField(max_length=255, verbose_name=_('county/state/province'), null=True, blank=True))
cls.add_to_class('postcode', models.CharField(max_length=15, verbose_name=_('postcode'), null=True))
cls.add_to_class('country', models.ForeignKey('countries.Country', null=True, blank=True))
cls.add_to_class('telephone', models.CharField(max_length=32, verbose_name=_('mobile number'), null=True, blank=True))
if admin_cls:
admin_cls.search_fields += ['address1', 'address2', 'city', 'region', 'postcode']
admin_cls.list_display_filter += ['country', ]
if admin_cls.fieldsets:
admin_cls.fieldsets.append((_('Address'), {
'fields': ['address1', 'address2','city', 'region', 'postcode', 'country', 'telephone'],
'classes': ('collapse',),
}))
### Dependencies
The address extension requires
[`incuna-countries`](http://github.com/incuna/incuna-countries). Add
`countries` to your `INSTALLED_APPS`.
The options and notification extensions require
[`django-orderable`](http://github.com/incuna/django-orderable). Add
`orderable` to your `INSTALLED_APPS`.
Metadata
Release files for django-extensible-profiles 1.3.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-extensible-profiles-1.3.6.tar.gz | 14.8 kB | Without provenance | Details for django-extensible-profiles-1.3.6.tar.gz |
Release files / django-extensible-profiles-1.3.6.tar.gz
| Download URL | django-extensible-profiles-1.3.6.tar.gz |
|---|---|
| Size | 14.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e82b347c78cd54c283cab06990a6aa7dfc45275b9e36816016fddbc8b3319e32
|
|
BLAKE2b-256 checksum How to use checksums |
9a00523a3f820312a98e04e2bf460fbcad5305392c490f57a2793a2b04712454
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-extensible-profiles 1.3.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.