Opened 9 years ago
Last modified 9 years ago
#26770 closed Cleanup/optimization
Migrations on app named 'settings' fails when callable default on a field present — at Version 1
Reported by: | Louis Lang | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 1.9 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
This seems to be a trivial issue that is reasonably resolved by simply renaming the settings
application (an app that I created). However, given that the migrations file (snippet below) was generated by Django and the imports clobber one another it seems reasonable enough consider this a bug.
# -*- coding: utf-8 -*- # Generated by Django 1.9.7 on 2016-06-17 03:12 from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models import django.db.models.deletion import settings.models class Migration(migrations.Migration): initial = True dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='Setting', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(blank=True, max_length=250, null=True)), ('email', models.EmailField(blank=True, max_length=254, null=True)), ('phone', models.CharField(blank=True, max_length=20, null=True)), ('url', models.URLField(blank=True, null=True)), ('paypal_email', models.EmailField(blank=True, max_length=254, null=True)), ], ), migrations.CreateModel( name='Theme', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=250, unique=True)), ('preview_image', models.ImageField(upload_to=settings.models.get_preview_path)), ('description', models.CharField(max_length=1000)), ('premium_user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], ), migrations.CreateModel( name='ThemeAttribute', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=250)), ('type', models.CharField(choices=[(b'1', b'TextArea'), (b'2', b'Image'), (b'3', b'TextField')], max_length=1)), ('width', models.IntegerField(blank=True, null=True)), ('height', models.IntegerField(blank=True, null=True)), ('description', models.CharField(max_length=2500)), ('theme', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attributes', to='settings.Theme')), ], ), migrations.CreateModel( name='ThemeImageAttribute', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('image', models.ImageField(blank=True, null=True, upload_to=settings.models.get_attribute_path)), ('attribute', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='image_attributes', to='settings.ThemeAttribute')), ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], ), migrations.CreateModel( name='ThemeTextAttribute', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('text', models.CharField(blank=True, max_length=5000, null=True)), ('attribute', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='text_attributes', to='settings.ThemeAttribute')), ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], ), migrations.CreateModel( name='ThemeTextFieldAttribute', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('text', models.CharField(blank=True, max_length=500, null=True)), ('attribute', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='textfield_attributes', to='settings.ThemeAttribute')), ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], ), migrations.AddField( model_name='setting', name='theme', field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='settings.Theme'), ), migrations.AddField( model_name='setting', name='user', field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), ), migrations.AlterUniqueTogether( name='themeattribute', unique_together=set([('theme', 'name')]), ), ]
This results in the following error message:
Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/home/user/Projects/shop/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line utility.execute() File "/home/user/Projects/shop/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/user/Projects/shop/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv self.execute(*args, **cmd_options) File "/home/user/Projects/shop/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute output = self.handle(*args, **options) File "/home/user/Projects/shop/venv/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 89, in handle executor = MigrationExecutor(connection, self.migration_progress_callback) File "/home/user/Projects/shop/venv/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 20, in __init__ self.loader = MigrationLoader(self.connection) File "/home/user/Projects/shop/venv/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 49, in __init__ self.build_graph() File "/home/user/Projects/shop/venv/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 170, in build_graph self.load_disk() File "/home/user/Projects/shop/venv/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 105, in load_disk migration_module = import_module("%s.%s" % (module_name, migration_name)) File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/home/user/Projects/shop/settings/migrations/0001_initial.py", line 11, in <module> class Migration(migrations.Migration): File "/home/user/Projects/shop/settings/migrations/0001_initial.py", line 16, in Migration migrations.swappable_dependency(settings.AUTH_USER_MODEL), AttributeError: 'module' object has no attribute 'AUTH_USER_MODEL'
Change History (1)
comment:1 by , 9 years ago
Description: | modified (diff) |
---|---|
Summary: | Migrations on app named 'settings' fails → Migrations on app named 'settings' fails when callable default on a field present |
Note:
See TracTickets
for help on using tickets.