BobBowles / django-diary

A diary app for use in the django framework.
MIT License
19 stars 3 forks source link

Cannot install with custom User model #3

Open ishankhare07 opened 4 years ago

ishankhare07 commented 4 years ago

Hi, I have a custom user model defined. For this reason I already have settings.AUTH_USER_MODEL set. But going through the installation docs, when I run manage.py migrate I get the following error:

ERRORS:
diary.Customer.user_ptr: (fields.E301) Field defines a relation with the model 'auth.User', which has been swapped out.
        HINT: Update the relation to point at 'settings.AUTH_USER_MODEL'.
diary.Entry.creator: (fields.E301) Field defines a relation with the model 'auth.User', which has been swapped out.
        HINT: Update the relation to point at 'settings.AUTH_USER_MODEL'.
diary.Entry.editor: (fields.E301) Field defines a relation with the model 'auth.User', which has been swapped out.
        HINT: Update the relation to point at 'settings.AUTH_USER_MODEL'.

Currently I've already set settings.AUTH_USER_MODEL='core.User'

BobBowles commented 4 years ago

I need more details about how you have set up your user customisation before I can usefully comment very much on this.

However, what I can say is that django-diary uses a Customer model that subclasses the default User. If you are using a different User model in your app that is likely to cause complications in several places. The first such place is in the migrations. Secondly, you are likely to need to create and install your own authentication backend in such a way that django-diary works harmoniously with your own code.

If you look at the setup of the example test app it is designed in such a way that Users typically have admin rights, while Customers have much more restricted access, and in particular cannot see or modify each others' details.