django-migrations

Django 1.7 migration cannot find app

狂风中的少年 提交于 2019-12-04 10:38:39
I'm creating a data migration for app Notification , in here i'm using the reference of model, Manager , from app accounts Manager = apps.get_model("accounts", "Manager") It throws error : self.code(from_state.render(), schema_editor) File "/home/notifications/migrations/0004_auto_20150720_0127.py", line 12, in set_notification_setttings Manager = apps.get_model("accounts", "Manager") File "/home/local/lib/python2.7/site-packages/django/apps/registry.py", line 202, in get_model return self.get_app_config(app_label).get_model(model_name.lower()) File "/home/local/lib/python2.7/site-packages

Circular dependency error when running migrations in Django 1.7c2

你说的曾经没有我的故事 提交于 2019-12-04 05:52:25
I have been reading about django migrations at https://docs.djangoproject.com/en/1.7/topics/migrations/ . I also reviewed the commits on the 1.7.x branch in github where I understand that this problem may have been solved. Unfortunately I still get the error when running my migrations. The --fake option gives the same error. I have the following migrations: 'people' app migration: user@host$ /manage.py makemigrations people Migrations for 'people': 0001_initial.py: - Create model Person - Create model Committee - Create model DepartmentGroup - Add field department_group to person - Create

How can I send signals from within Django migrations?

左心房为你撑大大i 提交于 2019-12-04 02:57:57
问题 I use Django 1.7 migrations, and in particular, want to populate a newly-created database with initial data. Thus, I use a data migration for this. It looks like this: def populate_with_initial_data(apps, schema_editor): User = apps.get_model("auth", "User") new_user = User.objects.create(username="nobody") class Migration(migrations.Migration): ... operations = [ migrations.RunPython(populate_with_initial_data), ] At the same time, I want to have an instance of the UserDetails model for

django.db.utils.IntegrityError: column “venue_city” contains null values

时间秒杀一切 提交于 2019-12-04 02:51:31
I have read a lot of other posts here on stackoverflow and google but I could not find a solution. It all started when I changed the model from a CharField to a ForeignKey. The error I recieve is: Operations to perform: Synchronize unmigrated apps: gis, staticfiles, crispy_forms, geoposition, messages Apply all migrations: venues, images, amenities, cities_light, registration, auth, admin, sites, sessions, contenttypes, easy_thumbnails, newsletter Synchronizing apps without migrations: Creating tables... Running deferred SQL... Installing custom SQL... Running migrations: Rendering model

ValueError in Django when running the “python manage.py migrate” command

落爺英雄遲暮 提交于 2019-12-04 02:48:29
I needed to add more fields to Django's User model, so I created a custom model class (named Accounts in an app named accounts ) that extends Django's AbstractUser class. After that, I updated my settings.py file, defining the AUTH_USER_MODEL property : AUTH_USER_MODEL = 'accounts.Accounts' I then created a migration file for the custom model using the python manage.py makemigrations command. After that, I ran the python manage.py migrate command and I got this error message: ValueError: The field admin.LogEntry.user was declared with a lazy reference to 'accounts.accounts', but app 'accounts'

Why does Django create migration files for proxy models?

有些话、适合烂在心里 提交于 2019-12-04 01:10:02
I just created a proxy model and was surprised that manage.py makemigrations creates a new migration file with a migrations.CreateModel operation. A proxy model does not create a new database table, it's just a different python interface to the same dataset and indeed manage.py sqlmigrate my_app_label 0042 returns nothing. I thought that it might be used to create the proxy model ContentType but those are created on demand if they don't exist. Is it used to trigger the creation of the proxy model permissions? There's a 6 year old open bug on proxy model permissions so I'm not really sure how

Django migrations using RunPython to commit changes

别说谁变了你拦得住时间么 提交于 2019-12-04 00:06:28
I want to alter a foreign key in one of my models that can currently have NULL values to not be nullable. I removed the null=True from my field and ran makemigrations Because I'm an altering a table that already has rows which contain NULL values in that field I am asked to provide a one-off value right away or edit the migration file and add a RunPython operation. My RunPython operation is listed BEFORE the AlterField operation and does the required update for this field so it doesn't contain NULL values (only rows who already contain a NULL value). But, the migration still fails with this

Getting a “The following content types are stale and need to be deleted” when trying to do a migrate. What does this mean, and how can I solve it?

不想你离开。 提交于 2019-12-03 23:53:34
This is my models.py: class Notification(models.Model): user = models.ForeignKey(User) createdAt = models.DateTimeField(auto_now_add=True, blank=True) read = models.BooleanField(default=False, blank=True) class Meta: abstract = True class RegularNotification(Notification): message = models.CharField(max_length=150) link = models.CharField(max_length=100) class FNotification(Notification): # same as Notification pass When I do python manage.py makemigrations , this is what it says: Migrations for 'CApp': 0019_auto_20151202_2228.py: - Create model RegularNotification - Create model FNotification

Why does django 1.7 creates migrations for changes in field choices?

雨燕双飞 提交于 2019-12-03 23:47:16
问题 I have observed this behaviour on version 1.7 but not in previous versions using south migration. eg. class RedemptionCode(models.Model): EXPIRE_OPTIONS = ( ('1 week', '1 Week'), ) expire_option = models.CharField(max_length=255, choices=EXPIRE_OPTIONS) when I added more options: EXPIRE_OPTIONS = ( ('1 week', '1 Week'), ('2 weeks', '2 Weeks'), ('1 month', '1 Month'), ('1 day', '1 Day'), ) and run makemigrations , it creates a migration for it, coming from south background I thought it should

Migrations in Django 1.7

穿精又带淫゛_ 提交于 2019-12-03 21:03:07
I am currently involved in a project where I am using Django 1.7 development version.I want to propogate changes that I make in my models (adding a field, deleting a model, etc.) into the database schema using "makemigrations" and "migrate" commmands.I added a "age" field to one of the models in my application. country = models.CharField(max_length=50, blank=True) address = models.CharField(max_length=100, blank=True) postal_code = models.IntegerField(max_length=50, blank=True) city = models.CharField(max_length=50, blank=True) phone_no = models.CharField(max_length=25, blank=True) skype_name