In my application I have students, professors and staff. Staff members do not need a profile but professors and students each need a different profile. I'd rather not implement it all myself (middleware and whatnot), so is there anyway to just have get_profile() return a different profile depending on a user's role?
相关问题
- Django __str__ returned non-string (type NoneType)
- Django & Amazon SES SMTP. Cannot send email
- Django check user group permissions
- Django restrict pages to certain users
- UnicodeEncodeError with attach_file on EmailMessag
相关文章
- Profiling Django with PyCharm
- Why doesn't Django enforce my unique_together
- MultiValueDictKeyError in Django admin
- Django/Heroku: FATAL: too many connections for rol
- Django is sooo slow? errno 32 broken pipe? dcramer
- Django: Replacement for the default ManyToMany Wid
- Upgrading transaction.commit_manually() to Django
- UnicodeEncodeError when saving ImageField containi
With Django 1.1, which is currently in beta, I would implement a proxy model.
get_profile needs the caching code from the original and so on. But essentially you could do something like that.
With Django 1.0.x you could implement derived classes based on User, but this might break code in other places. For stuff like that I love proxy classes, which just add python functionality without changing the database models.
Have you rad http://docs.djangoproject.com/en/dev/topics/auth/#auth-profiles?
That's the standard solution.