I found information
here
https://groups.google.com/forum/#!searchin/django-users/auth$20user$20in$20migration|sort:relevance/django-users/Zz9rKT7GVM0/u6A4HzgDylkJ
but I want not use "patching"
I did following:
def create_superuser(apps, schema_editor):
# fixme: User = apps.get_model("auth", "User")
from django.contrib.auth.models import User
User.objects.create_superuser(username='admin',
password='admin123admin', email='')
It works
воскресенье, 18 декабря 2016 г., 14:25:31 UTC+4 пользователь Павел Фролов
написал:
>
> Hello everybody,
>
> could somebody help me
> I try to do data migration. Migration uses User from auth. Django 1.10.4
>
> def create_superuser(apps, schema_editor):
> User = apps.get_model("auth", "User")
> User.objects.create_superuser(username='admin',
> password='admin123admin', email='')
>
> class Migration(migrations.Migration):
> dependencies = [
> ('auth', '__latest__'),
> ]
> operations = [
> migrations.RunPython(create_superuser),
> ]
>
> I got an error:
> ...
> File "/Projects/django/src/testdb/migrations/0001_initial.py", line 10, in
> create_superuser
> User.objects.create_superuser(username='admin',
> password='admin123admin', email='')
> File
> "/Projects/django/venv/lib/python3.4/site-packages/django/contrib/auth/models.py",
>
> line 168, in create_superuser
> return self._create_user(username, email, password, **extra_fields)
> File
> "/Projects/django/venv/lib/python3.4/site-packages/django/contrib/auth/models.py",
>
> line 148, in _create_user
> username = self.model.normalize_username(username)
> AttributeError: type object 'User' has no attribute 'normalize_username'
>
> I use standard User in my project and I need perform data migrations.
>
> thank you in advance
> Pavel
>
--
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 [email protected].
To post to this group, send email to [email protected].
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/ba4fdf6f-b125-4f7c-bfd5-e551f10fe655%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.