Goal: automatically creating a superuser I’m trying to create a default user, specifically a superuser, in an early data migration, so whenever my Django application is run in my Docker container, it already has a superuser with which I can access the admin site. I had already tried different options for creating said superuser, and although I have some functioning
Tag: django-migrations
Custom field – got multiple values for keyword argument ‘related_name’
I’m working on a custom field that is just a shortcut to ForeignKey that points to addresses.Country model. When I run makemigrations it returns this error with I’m not sure: I understand that there are two to arguments passed but I don’t understand why. It looks like the field is initialized two times. Once with the kwargs I provided and
Django migrations error: dont create authomatically permissions and contenttypes
I work with django 1.8.7 and python 2.7 . I have peoblem with migrate. when I migrate my models , permission and contenttypes don’t create automatically. error looks like this: and when I change migrations file like this: and run command ” python manage.py migrate ” this is responsed: thanks for your help. :) Answer I find the solution, in
Django 2.2 cannot serialize default values once migration has been done
I have a model which is refered to as a foreignkey with on_delete set to SET_DEFAULT. Because of that, I need to provide this model with a default item. I created a static method which does just that. I am able to run makemigrations and migrate without issue. My problem starts when I modifiy my models and try to use
How to populate auth.groups and auth.group_permissions tables with initial data in Django project
Context I am using PostgreSQL. I would like to immediately populate the auth.groups and auth.group_permissions tables, after the very first migration of my project. So, after I have set up these tables the way I want them, I dump them by running The resulting file is this The problem To try this, I drop and recreate my db, so that
Handling data during django migrations?
I have created this model. Let suppose I have added a new field called After that If I run command python manage.py makemigrations, then django will add a new field status in table. Let’s I have 3 rows in the table, then value will be as below: With this migration, I also want to change the status of every row
“OperationalError: no such table: django_site” when running makemigrations with empty database when using Django-todo
I have inherited a Django 1.11.6 application from another developer. Now after I have made a lot of changes to the code and data model, I want to re-create the sqlite database from scratch. But when I run manage.py makemigrations in the project directory (no migration files and database present), I am getting the following error message: ‘django.contrib.sites’ is present
InvalidBasesError: Cannot resolve bases for []
When I run tests I get this error during database initialization: I created this proxy for contrib.auth Group model to place it in my app in django admin: So what can I do to fix this issue? Answer After a lot of digging on this the only thing that worked for me was comment out the offending apps, run migrations,
Django migration strategy for renaming a model and relationship fields
I’m planning to rename several models in an existing Django project where there are many other models that have foreign key relationships to the models I would like to rename. I’m fairly certain this will require multiple migrations, but I’m not sure of the exact procedure. Let’s say I start out with the following models within a Django app called