What is the best approach to change primary keys in an existing Django app?

Agreed, your model is probably wrong. The formal primary key should always be a surrogate key. Never anything else. [Strong words. Been database designer since the 1980’s. Important lessoned learned is this: everything is changeable, even when the users swear on their mothers’ graves that the value cannot be changed is is truly a natural … Read more

django no such table:

Updated answer for Django migrations without south plugin: Like T.T suggested in his answer, my previous answer was for south migration plugin, when Django hasn’t any schema migration features. Now (works in Django 1.9+): T.T wrote: You can try this! python manage.py makemigrations python manage.py migrate –run-syncdb Outdated for south migrations plugin As I can … Read more

How to reset migrations in Django 1.7

I would just do the following on both the environments (as long as the code is the same) Delete your migrations folder DELETE FROM django_migrations WHERE app = <your app name> . You could alternatively just truncate this table. python manage.py makemigrations python manage.py migrate –fake After this all your changes should get detected across … Read more

django 1.7 migrate gets error “table already exists”

If you have the table created in the database, you can run python manage.py migrate –fake <appname> Mark migrations as run without actually running them Or if you want to avoid some actions in your migration, you can edit the migration file under the app/migrations directory and comment the operations you don’t want to do … Read more

How do I migrate a model out of one django app and into a new one?

How to migrate using south. Lets say we got two apps: common and specific: myproject/ |– common | |– migrations | | |– 0001_initial.py | | `– 0002_create_cat.py | `– models.py `– specific |– migrations | |– 0001_initial.py | `– 0002_create_dog.py `– models.py Now we want to move model common.models.cat to specific app (precisely to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)