Tuesday, December 29, 2015

Re: Django 1.8: subclass AbstractUser, App 'auth' doesn't have a 'myuser' model.

2015-10-14 23:13 GMT-03:00 술욱 <nbensa@gmail.com>:
2015-10-14 15:21 GMT-03:00 syl pingus <sylpingus@hotmail.fr>:
> Hello Norberto,
>
> In your first example, I think the name of your apps in the apps.py config
> file conflicts with the core Django auth module and it could explains the
> second exception you get.

Yes. I know, that's why I added label="myauth". The problem is Django
1.6 allowed to call it 'auth'. Yes, it was our fault, we should have
called it accounts or something else.


> When you use a custom model in Django, the "migrate" command always create
> additional table for group and user_permissions but they are never filled in
> throught the admin site. According to me, Django creates these tables but
> they are useless. Why ? I don't really know... Maybe it's depending on the
> table creation process.

I'm sorry, I think I'm not following you. Are you saying myauth_myuser
are not used?

If I migrate this app to 1.8.5, and I add label="myauth" to avoid
collision with django.contrib.auth, I lose the users. They're in the
auth_myuser table, myauth_myuser is empty. If I create a user, the
user is created in myauth_myuser table.


> Sorry, my answer doesn't really help you but that's is my understanding of
> custom user model process at this time.

Don't worry. I'll make a dB dump, change the tables by hand and import
everything with label='myauth'. I was hoping there was a "Django way"
to fix this problem.

Thanks,
Norberto

I fixed this problem.


I renamed my app 'auth' to 'accounts' and then changed all the references of auth.something to accounts.something.

I renamed the tables and sequences (I use postgres):

auth_myuser -> accounts_myuser
auth_myuser_id_seq -> accounts_myuser_id_seq
etc.

I removed the southmigrations table.

Also changed django_content_type as described in the above post.

Then I upgraded to django<1.8, then <1.9, and lastly 1.9. I couldn't upgrade directly to 1.9.


Thanks all,

Regards,
Norberto

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADut3oBYEMqVKwhJ8iZO10XXFn7QEswBA%3DpWFQ-dgZ3%2BPcMuTg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment