Questions tagged [makemigrations]

This is the first step in the two step process to sync changes made to the Django model (in python code) with the database.

https://docs.djangoproject.com/en/1.11/ref/django-admin/#django-admin-makemigrations

113 questions
2
votes
1 answer

ForeignKey(unique=True) is usually better served by a OneToOneField

class Categories(models.Model): id = models.ForeignKey('auth.User',primary_key=True) name = models.CharField(max_length=100) description = models.CharField(max_length=300) def __str__(self): return Categories.name class…
A.Raouf
  • 2,171
  • 1
  • 24
  • 36
2
votes
1 answer

Django makemigrations in PyCharm

When I add new field without default value to my model some_field = models.IntegerField() and run makemigrations I get this message `You are trying to add a non-nullable field 'some_field' to sometable without a default; we can't do that (the…
Dima Kudosh
  • 7,126
  • 4
  • 36
  • 46
2
votes
0 answers

django 1.7.1 - migrate: django.db.migrations.graph.CircularDependencyError

I have an existing app which has two models: class A(models.Model): #... class B(models.Modele): a = models.ForeignKey(A) # .. and I had django 1.6, now I upgraded to 1.7.1 and I did: python manage.py makemigrations myapp and it created…
doniyor
  • 36,596
  • 57
  • 175
  • 260
1
vote
2 answers

Multiple migrations are created each time in Django

I have a model in my app : class PutAwayProductsPosition(models.Model): products = models.ForeignKey(Product, on_delete=models.CASCADE) put_position = models.CharField(max_length=50, default=0) is_put =…
1
vote
1 answer

The problem of not recognizing max_length in Django

class ConcerModel(models.Model): Name=models.CharField(max_length=100) singerName=models.CharField(max_length=100) lenght=models.CharField() def __str__(self): return self.singerName class locationModel…
1
vote
2 answers

why django can not create a table after deleting the table and the migration files of the app?

I am working with Django v4.* which I connected it to Postgres DB on the localhost, I have created my model (Article) then makemigrations then migrate then I have changed the model by adding extra field, as a result it didn't take effect so I have…
Yusuf
  • 2,295
  • 7
  • 15
  • 34
1
vote
1 answer

django makemigrations nomodule found error

I am trying to add models, but whenever I run python manage.py makemigrations I get the following error ModuleNotFoundError: No module named 'django.contrib.staticfilesaccounts' accounts is an app in my project, the structure of the files is as…
Qwerty
  • 13
  • 3
1
vote
1 answer

Can I specify a custom default value to be used when migrating after adding a new parent class in a Django model?

I am writing a Django app that provides a very simple model called Submittable, which users of the app are supposed to inherit from when they want to use other functionalities of the app. # app1 class Submittable(models.Model): is_submitted =…
andreashhp
  • 485
  • 2
  • 16
1
vote
2 answers

I'm getting an error message when making migration to db in django

hello guys I'm doing a django tutorial and i missed a change the instructor did in models.py so i fix it but when trying to make the migration to the db it gives me a code that I don't understand or i don't know what to do, here is what it…
1
vote
3 answers

Problems with "Makemigrations" in django

I'm trying to run "python manage.py makemigrations" but appears "No changes detected" . I had done changes so I don't know where is the problem. HELP!
serbenar
  • 13
  • 2
1
vote
1 answer

Running manage.py makemigrations for multiple databases in django

I'm trying to use multiple databases in my Django project i.e. MongoDB and MySQL. # settings.py DATABASES = { 'default': { 'NAME': 'sql_db', 'ENGINE': 'django.db.backends.mysql', 'USER': 'root', 'PASSWORD':…
danish2694
  • 199
  • 3
  • 16
1
vote
0 answers

moving Django Project from windows to Mac migration

I moved my project from my windows machine to Mac using GitHub when I run python manage.py runserver it worked fine showing my login page and since I didn't do any migration the app crashed, so I executed python manage.py makemigrations I thought…
IOS777
  • 35
  • 3
  • 9
1
vote
2 answers

im not able to makemigrations to my already built model after extending user model to it in django

im just stuck with error while making migrations to my django project. in my project which is already 50% dveloped i use owner model to represent owner of shop and then i used user model for login and for registration purpose. so i tried to use user…
1
vote
1 answer

how to migrate django models to new database

i develope a django project on my local system, and now i deployed that to a server. i used MySql as database. whenever i try to migrate my models (using python manage.py migrate or python manage.py makemigrations) to server's new database, it shows…
Omid Adib
  • 170
  • 1
  • 8
1
vote
0 answers

Makemigrations gives ValueError: too many values to unpack

I have a working project and I would like to add one new field to one of the models. I have added the new field and ran the makemigrations command and then I got ValueError: too many values to unpack This is the model: class Line(models.Model): …
The Maestro
  • 659
  • 1
  • 5
  • 21