Question

I am designing a Django application (v1.6) and need to do several things with users:

  1. Add custom fields, such as a foreign key for user department
  2. Trigger database changes when certain fields change. For example, when the user's department changes I need to move inventory in another model out of the old department and into the new. I was planning to use a pre_save receiver to do this.
  3. Define custom permissions, such as a user can only modify rows in a table that are associated with their department.
  4. Eventually I want to integrate the application with our Active Directory server for authentication.

I looked at the options in the documentation and see that there are several options, from extending the user model with a one-to-one relationship to writing a custom user model.

What design should I use to meet all of the above goals?

Était-ce utile?

La solution

Take a look at this blog post: it provides all the design principles to achieve your goals. http://www.roguelynn.com/words/django-custom-user-models/

I would also take a look here for more information about Configurable User Models, if you want to have your own authentication scheme: http://procrastinatingdev.com/django/using-configurable-user-models-in-django-1-5/

Autres conseils

I also found the following reference helpful: http://www.sofokus.com/blogi/custom-user-model/

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top