django-1.7

Django 1.7 upgrade error: AppRegistryNotReady: Apps aren't loaded yet

99封情书 提交于 2019-11-28 17:08:58
I am trying to upgrade a project from Django 1.6 to 1.7. I get the following error: [Thu Oct 09 14:16:41 2014] [error] [client 95.79.172.156] mod_wsgi (pid=14523): Exception occurred processing WSGI script '/home/users1/k/kisvadim/domains/mathtasks.org/django.wsgi'. [Thu Oct 09 14:16:41 2014] [error] [client 95.79.172.156] Traceback (most recent call last): [Thu Oct 09 14:16:41 2014] [error] [client 95.79.172.156] File "/home/users1/k/kisvadim/virtualenv/PythonEnv/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 187, in __call__ [Thu Oct 09 14:16:41 2014] [error] [client 95.79

Django 1.7 migrations won't recreate a dropped table, why?

▼魔方 西西 提交于 2019-11-28 16:44:03
问题 Using Django 1.7 migrations. I accidentally dropped a table in my database. I assumed that by running migration again this would recreate the table but no, Django states "No migrations to apply". How to I get Django to recreate the table? I have run: > makemigrations - No changes detected > migrate - No migrations to apply. I have tried making a change to the model and running a new migration and it simply states that "Table 'x.test_customer' doesn't exist" which is correct, but what I was

How to add a new field to a model with new Django migrations?

北战南征 提交于 2019-11-28 16:14:15
I'm using the contribute_to_class method but I don't know how to create the field in the database with new migrations. Nima To answer your question, with the new migration introduced in Django 1.7 , in order to add a new field to a model you can simply add that field to your model and initialize migrations with ./manage.py makemigrations and then run ./manage.py migrate and the new field will be added to your DB. To avoid dealing with errors for your existing models however, you can use the --fake : Initialize migrations for your existing models: ./manage.py makemigrations myapp Fake

How to migrate back from initial migration in Django 1.7?

心不动则不痛 提交于 2019-11-28 05:35:46
I created a new app with some models and now I noticed that some of the models are poorly thought out. As I haven't committed the code the sensible thing would be to migrate the database to last good state and redo the migration with better models. In this case the last good state is database where the new app doesn't exist. How can I migrate back from initial migration in Django 1.7? In South one could do: python manage.py migrate <app> zero Which would clear <app> from migration history and drop all tables of <app> . How to do this with Django 1.7 migrations? ChillarAnand You can do the same

Creating Partial Indexes with Django 1.7

五迷三道 提交于 2019-11-27 22:56:43
The documentation for Django 1.7 mentions RunSQL classes can be used to create partial indexes on your tables. I have a table where I want the combination of title , blog & category to be unique. However if category is not provided, the combination of title & blog should still be unique. class Post(models.Model): title = models.CharField(max_length=200) blog = models.ForeignKey(Blog) category = models.ForeignKey(Category, null=True, blank=True) I can achieve this constraint with partial indexes (like the SQL shown below). Where do I add this code if I'm using Django 1.7 migrations? CREATE

Why does Django make migrations for help_text and verbose_name changes?

夙愿已清 提交于 2019-11-27 17:06:36
问题 When I change help_text or verbose_name for any of my model fields and run python manage.py makemigrations , it detects these changes and creates a new migration, say, 0002_xxxx.py . I am using PostgreSQL and I think these changes are irrelevant to my database (I wonder if a DBMS for which these changes are relevant exists at all). Why does Django generate migrations for such changes? Is there an option to ignore them? Can I apply the changes from 0002_xxxx.py to the previous migration ( 0001

Django 1.7 upgrade error: AppRegistryNotReady: Models aren't loaded yet

回眸只為那壹抹淺笑 提交于 2019-11-27 13:14:01
I am trying to upgrade a project from Django 1.6 to 1.7. So far, I have created a new virtualenv with all the same installs and upgraded the Django version to the new release. I need to upgrade from South, but had errors doing so, so I thought I'll initially just try runserver, and I get the following error: Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/Users/Name/.virtualenvs/test17/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line utility.execute() File "/Users/Name/

django 1.7 migrate gets error “table already exists”

微笑、不失礼 提交于 2019-11-27 10:55:20
I am trying to apply a migration but am getting the error: django.db.utils.OperationalError: (1050, "Table 'customers_customer' already exists") I get this by issuing the following command: python manage.py migrate My customer table already exists, so what do I do to let the migration know this, not error out, and run my modification to my model? I ran this on my local environment with local database with no problem. It is when I pointed my database to production and ran migrate above that I get this error. If you have the table created in the database, you can run python manage.py migrate -

Django 1.7 upgrade error: AppRegistryNotReady: Apps aren't loaded yet

余生长醉 提交于 2019-11-27 10:13:32
问题 I am trying to upgrade a project from Django 1.6 to 1.7. I get the following error: [Thu Oct 09 14:16:41 2014] [error] [client 95.79.172.156] mod_wsgi (pid=14523): Exception occurred processing WSGI script '/home/users1/k/kisvadim/domains/mathtasks.org/django.wsgi'. [Thu Oct 09 14:16:41 2014] [error] [client 95.79.172.156] Traceback (most recent call last): [Thu Oct 09 14:16:41 2014] [error] [client 95.79.172.156] File "/home/users1/k/kisvadim/virtualenv/PythonEnv/lib/python2.7/site-packages

How to add a new field to a model with new Django migrations?

◇◆丶佛笑我妖孽 提交于 2019-11-27 09:32:35
问题 I'm using the contribute_to_class method but I don't know how to create the field in the database with new migrations. 回答1: To answer your question, with the new migration introduced in Django 1.7 , in order to add a new field to a model you can simply add that field to your model and initialize migrations with ./manage.py makemigrations and then run ./manage.py migrate and the new field will be added to your DB. To avoid dealing with errors for your existing models however, you can use the -