﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
22853	auth.0001_initial migration fails when there is a custom user model	Vidir Valberg Gudmundsson	nobody	"=== Models ===
{{{#!python
from django.db import models
from django.contrib.auth.models import AbstractUser


class Profile(AbstractUser):
    title = models.CharField(max_length=255)
}}}


=== Migration===
{{{#!python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import django.core.validators
import django.utils.timezone


class Migration(migrations.Migration):

    dependencies = [
        ('auth', '__first__'),
    ]

    operations = [
        migrations.CreateModel(
            name='Profile',
            fields=[
                ('id', models.AutoField(serialize=False, verbose_name='ID', auto_created=True, primary_key=True)),
                ('password', models.CharField(max_length=128, verbose_name='password')),
                ('last_login', models.DateTimeField(default=django.utils.timezone.now, verbose_name='last login')),
                ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
                ('username', models.CharField(help_text='Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=30, unique=True, validators=[django.core.validators.RegexValidator('^[\\w.@+-]+$', 'Enter a valid username.', 'invalid')], verbose_name='username')),
                ('first_name', models.CharField(max_length=30, blank=True, verbose_name='first name')),
                ('last_name', models.CharField(max_length=30, blank=True, verbose_name='last name')),
                ('email', models.EmailField(max_length=75, blank=True, verbose_name='email address')),
                ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
                ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
                ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
                ('title', models.CharField(max_length=255)),
                ('groups', models.ManyToManyField(blank=True, to='auth.Group', verbose_name='groups')),
                ('user_permissions', models.ManyToManyField(blank=True, to='auth.Permission', verbose_name='user permissions')),
            ],
            options={
                'abstract': False,
                'verbose_name_plural': 'users',
                'verbose_name': 'user',
            },
            bases=(models.Model,),
        ),
    ]
}}}

=== Error ===
{{{
$ ./manage.py migrate
Operations to perform:
  Synchronize unmigrated apps: (none)
  Apply all migrations: testapp, sessions, contenttypes, auth, admin
Synchronizing apps without migrations:
  Creating tables...
  Installing custom SQL...
  Installing indexes...
Running migrations:
  Applying auth.0001_initial...Traceback (most recent call last):
  File ""./manage.py"", line 10, in <module>
    execute_from_command_line(sys.argv)
  File ""/Users/valberg/Code/forks/django/django/core/management/__init__.py"", line 385, in execute_from_command_line
    utility.execute()
  File ""/Users/valberg/Code/forks/django/django/core/management/__init__.py"", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""/Users/valberg/Code/forks/django/django/core/management/base.py"", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File ""/Users/valberg/Code/forks/django/django/core/management/base.py"", line 337, in execute
    output = self.handle(*args, **options)
  File ""/Users/valberg/Code/forks/django/django/core/management/commands/migrate.py"", line 146, in handle
    executor.migrate(targets, plan, fake=options.get(""fake"", False))
  File ""/Users/valberg/Code/forks/django/django/db/migrations/executor.py"", line 62, in migrate
    self.apply_migration(migration, fake=fake)
  File ""/Users/valberg/Code/forks/django/django/db/migrations/executor.py"", line 96, in apply_migration
    migration.apply(project_state, schema_editor)
  File ""/Users/valberg/Code/forks/django/django/db/migrations/migration.py"", line 107, in apply
    operation.database_forwards(self.app_label, schema_editor, project_state, new_state)
  File ""/Users/valberg/Code/forks/django/django/db/migrations/operations/models.py"", line 36, in database_forwards
    schema_editor.create_model(model)
  File ""/Users/valberg/Code/forks/django/django/db/backends/schema.py"", line 282, in create_model
    if field.rel.through._meta.auto_created:
AttributeError: 'NoneType' object has no attribute '_meta'
}}}

=== Occurrences ===
This happens at 57a770b8e586399926311d86639c6789a1563253 in `stable/1.7.x` and 61d7ae31cf286277ddefaf8006597be40388d2ee in `master`."	Bug	closed	Migrations	dev	Release blocker	fixed			Accepted	0	0	0	0	0	0
