Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Django User-Model or create a own Model?

I'm currently designing a Django based site. For simplicity lets assume that it is a simple community site where users can log in and write messages to other users.

My current choice is wether to use the buildin User-Model or to build something my own. I don't need much from the buildin User: there will be no username (you e-mail address is you username), but you an set an internal Name of your choice which can be used by multiple users (like Facebook). Additionally, I don't need the permission system, since access to others will not be based on groups. So I would end up using only the email, firstname, lastname and password fields from the buildin User and everything else would be placed in a UserProfile. On the other hand, the buildin User system will come handy on the backend of the site, since there is the chance I will need a group based permission system there.

All in all, it looks to me, that I rather build my one User Model and use the buildin only for access to the admin backend.

Is there anything wrong with my reflections?

like image 948
Martin Thurau Avatar asked Dec 16 '22 16:12

Martin Thurau


1 Answers

Is there anything wrong with my reflections?

Yes.

My current choice is wether to use the buildin User-Model or to build something my own.

There is a third choice.

http://docs.djangoproject.com/en/1.2/topics/auth/#storing-additional-information-about-users

everything else would be placed in a UserProfile

Correct.

build my one User Model and use the buildin only for access to the admin backend

Don't build your own.

Do this:

If you'd like to store additional information related to your users, Django provides a method to specify a site-specific related model -- termed a "user profile" -- for this purpose.

like image 112
S.Lott Avatar answered Dec 30 '22 02:12

S.Lott