On Tuesday, 18 November 2014 15:04:19 UTC, Tobias Dacoir wrote:
>
> I'm trying to figure out how to create my Custom User Model.
>
> In the official docs I basically found two different strategies: Extending 
> User Model or Custom User Model: 
> https://docs.djangoproject.com/en/1.7/topics/auth/customizing/#extending-the-existing-user-model
>
> Extending means I have a OnetoOne Relationship to the User Table in my own 
> UserProfile Model, whereas the other method inherits from AbstractBaseUser 
> and looks quite complicated with a lot of warnings that I can't not change 
> this easily after I created my database.
>
> I want to design a web app where users can log in and once log in take 
> some kind of surveys. For this I want to make use of Django's 
> Authentication methods, so only registered and logged in Users can take 
> part in the survey. However I want to save additional data for each User in 
> the database, like Age, Country, Score and so on. In the Admin interface it 
> would be great if I could just select a User Entry and see all fields, the 
> default from the User Model plus my added fields.
>
> It might be a good idea to use OAuth later on as well, to be able to have 
> users authenticate through Facebook and so on, however that is not required 
> right now (I did create quick test project for the social auth plugin and 
> it worked). Still I don't really understand the differences between those 
> two methods and google didn't help me because most tutorials show either 
> route but never say why one is better than the other. 
>
> So which should I use in my case?
>


In the case you describe, there's not really a lot to choose between the 
two approaches. Either you extend the user model with a related profile, in 
which case you configure the admin to show the profile as an inline 
underneath the main fields, or you substitute your own model (which 
probably inherits from AbstractUser), in which case the admin shows all the 
fields in one section. Personally I prefer the tidiness of custom models, 
especially as you save a db query every time.
--
DR.

-- 
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+unsubscr...@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/6086f880-2bf1-4de7-a59e-a123334ce32c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to