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

2015-10-14 Thread syl pingus
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.

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.

If you want to use group and permissions with your custom model, it will be 
stored in auth_group, auth_group_permissions and auth_permissions tables.

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

Sylvain.
--
> From: nbe...@gmail.com
> Date: Wed, 14 Oct 2015 12:43:03 -0300
> Subject: Re: Django 1.8: subclass AbstractUser, App 'auth' doesn't have a 
> 'myuser' model.
> To: django-users@googlegroups.com
> 
> Hello Tim,
> 
> yes, I need to use the custom user model. The app is now in production
> (Django 1.6.11).
> 
> If I use settings.AUTH_USER_MODEL = 'auth.MyUser', I get the error
> described in my previous emails.
> 
> If I change to settings.AUTH_USER_MODEL = 'myauth.MyUser', I get the
> following tables created:
> 
> myauth_myuser
> myauth_myuser_groups
> myauth_myuser_user_permissions
> 
> Thanks,
> Norberto
> 
> 
> 2015-10-13 18:26 GMT-03:00 Tim Graham :
> > Do you want to use the custom user model or not? What extra tables are
> > created?
> >
> > On Tuesday, October 13, 2015 at 1:31:03 PM UTC-7, Norberto Bensa wrote:
> >>
> >> Hello,
> >>
> >> I'm re-posting this.
> >>
> >> Note that I already tried AUTH_USER_MODEL = "myauth.MyUser', and while
> >> that makes the problem disappear, the change also creates new tables
> >> in the database.
> >>
> >> What are my options? AFAIK 1.6 is deprecated for security reasons and
> >> I want to upgrade to 1.8.x.
> >>
> >> Thanks.
> >> Norberto
> >>
> >>
> >>
> >> -- Forwarded message --
> >> From: 술욱 
> >> Date: 2015-10-06 22:37 GMT-03:00
> >> Subject: Django 1.8: subclass AbstractUser, App 'auth' doesn't have a
> >> 'myuser' model.
> >> To: 'Tom 
> >>
> >>
> >> Hello,
> >>
> >> I'm trying to upgrade an app from Django 1.6 to 1.8 but I can't solve
> >> a problem apparently related to a custom user model.
> >>
> >> The project has an 'auth' app with its corresponding models.py and
> >> apps.py. The snippet pasted bellow reproduces the problem which I
> >> don't know how to fix.
> >>
> >> Many TIA,
> >> Norberto
> >>
> >>
> >> # auth/models.py
> >> from django.contrib.auth.models import AbstractUser
> >> from django.db import models
> >>
> >> class MyUser(AbstractUser):
> >> pass
> >>
> >>
> >> # auth/apps.py
> >> from django.apps import AppConfig
> >>
> >> class MyAuth(AppConfig):
> >> name = 'auth'
> >> label = 'myauth'
> >>
> >>
> >> # project/setting.py
> >>
> >> INSTALLED_APPS = (
> >> ...
> >> 'auth.apps.MyAuth',
> >> ...
> >> )
> >>
> >> AUTH_USER_MODEL = 'auth.MyUser'
> >>
> >>
> >> Note apps.py is there just because 'auth' collides with
> >> django.contrib.auth.
> >>
> >>
> >> $ ./manage.py makemigrations
> >> Traceback (most recent call last):
> >>   File
> >> "/home/ubuntu/.virtualenvs/testauth/lib/python3.4/site-packages/django/apps/config.py",
> >> line 159, in get_model
> >> return self.models[model_name.lower()]
> >> KeyError: 'myuser'
> >>
> >> During handling of the above exception, another exception occurred:
> >>
> >> Traceback (most recent call last):
> >>   File "./manage.py", line 10, in 
> >> execute_from_command_line(sys.argv)
> >>   File
> >> "/home/ubuntu/.virtualenvs/testauth/lib/python3.4/site-packages/django/core/management/__init__.py",
> >> line 351, in execute_from_command_line
> >> utility.execute()
> >>   File
> >> "/home/ubuntu/.virtualenvs/testauth/lib/python3.4/site-packages/django/core/management/__init__.py",
> >> line 343, in execute
> >> self.fetch_command(subcommand).run_from_argv(self.argv)
> >>   File
> >> "/home/ubuntu/.virtualenvs/testauth/lib/python3.4/site-packages/django/core/management/base.py",
> >> line 394, in run_from_argv
> >> self.execute(*args, **cmd_options)
> >>   File
> >> "/home/ubuntu/.virtualenvs/testauth/lib/python3.4/site-packages/django/core/management/base.py",
> >> line 444, in execute
> >> self.check()
> >>   File
> >> "/home/ubuntu/.virtualenvs/testauth/lib/python3.4/site-packages/django/core/management/base.py",
> >> line 482, in check
> >> include_deployment_checks=include_deployment_checks,
> >>   File
> >> "/home/ubuntu/.virtualenvs/testauth/lib/python3.4/site-packages/django/core/checks/registry.py",
> >> line 72, in run_checks
> >> new_errors = check(app_configs=app_configs)
> >>   File
> >> "/home/ubuntu/.virtualenvs/testauth/lib/python3.4/site-packages/django/contrib/auth/checks.py",
> >> line 12, in check_user_model
> >> cls = apps.get

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

2015-10-15 Thread syl pingus
Hi,

Your table myauth_myuser is used to store your users. But Django create 
additional custom tables for groups and user_permissions related to the custom 
user model and which are useless and I don't uderrstand why. If somebody have 
an explanation or could tell me how to avoid the creation of the following 
tables using the migrate command it could be great : myauth_group - 
myauth_user_permissions

Sylvain.
--
> From: nbe...@gmail.com
> Date: Wed, 14 Oct 2015 23:13:52 -0300
> Subject: Re: Django 1.8: subclass AbstractUser, App 'auth' doesn't have a 
> 'myuser' model.
> To: django-users@googlegroups.com
> 
> 2015-10-14 15:21 GMT-03:00 syl pingus :
> > 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
> 
> -- 
> 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/CADut3oCrCefSmnrzXg-Z20SjEvou2ob8Xr_47TGOMa7B_BrXbA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
  

-- 
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/DUB114-W116096DC9E097FAE55C1DA5CA3E0%40phx.gbl.
For more options, visit https://groups.google.com/d/optout.