Thursday, May 29, 2014

Re: How to create a custom user model ?

Hi Kirby,

Thank you very much for these detailed information.
Finally, I've went to the source code of Django's auth and I understand a bit better the process.

Thanks again

A.


On Thu, May 29, 2014 at 2:43 PM, C. Kirby <misthop@gmail.com> wrote:
Ah.
AbstractUser (AU) inherits from AbstractBaseUser (ABU).
ABU only provides password and last login fields. You should use it as your base class if you want to do something radically different from the  django user. The best example would be using email addresse for the username field.A standard Django User model is just a wrapper around the AU model. If you are happy with what the standard user is (Username, first, last, email, is_staff, is_admin, date joined, and the abstract base user fields) but want to add a few new fields, like in your case company_name.

For your questions:
1. you are correct that you need to register the custom user to the admin. You will also have to write an admin class as shown in the example. You will do it by admin.site.register(CustomUser, CustomUserAdmin)
2. Also correct. Just take the default forms and add the company_name field to them. Also just follow the example I linked to

Hope this helps some,
Kirby

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/I1-goX7LUA0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f89b0570-139f-4ddd-8ce7-9198b64dfc91%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
--------------------------------------------------------------------
Arnaud Vandecasteele
SIG - WebMapping - Spatial Ontology - GeoCollaboration

Web Site
http://www.marinegis.com/?page_id=131
http://geotribu.net/

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHZ2jmALiXOZtVeMQriKa%3D_XgFkyvG6%2Bf8Uya23z9vZXAtTZcQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment