Python manage.py makemigrations no changes detected

Hello,

I am at course Django video Creating migrations. After first run the command makemigrations there were all ok but I changed the model name from price to Unit_price and entered makemigrations error says no changed detected.

What is wrong here?

Hello YaPay,

Can you find your app in the list of installed apps in the settings-module?

yes, I checked already. Everythings seems ok but I could not find the problem. I am really newbie

Hello,

What happens if you run the command:
python manage.py migrate

If nothing happens maybe you could attach som screenshots? From project.settings INSTALLED_APPS and your projectstructure (so we can see what your apps are called).

python manage.py migrate

Operations to perform:
Apply all migrations: admin, auth, contenttypes, store
Running migrations:
No migrations to apply.

Hi,

So first you ran makemigrations, made your change to the model and then makemigrations again? Did you run migrate between the makemigrations? Was this your first migration?

If so, maybe you can find some clues on where to look in this stackoverflow-post:

So first you ran makemigrations, made your change to the model and then makemigrations again?

the first makemigrations works well after chaging some models and giving makemigrations again resulting: no change. This is the main problem

I did not run migrate between makemigrations.

Was this your first migration?

I am following the course. According the course if I change price name in Products model to unit_price makemigrations says there is a change. On me I see only no change.

Hi,

ok! What files do you have in your migrations folder?

and please send the content of the initial migration

if you mean init.py it is empty. No code in

i meant from the store app! If thats where you have your model?

I am really sorry if i give wrong information. I hope you meant this:

python manage.py makemigrations store  :heavy_check_mark: storefront-FK5d6ZFd Py
Migrations for ‘store’:
store/migrations/0001_initial.py
- Create model Adresses
- Create model Cart
- Create model CartItem
- Create model Collection
- Create model Customer
- Create model Order
- Create model OrderItem
- Create model Promotion
- Create model Product

Hi,

No problem :slight_smile:

Are there more migration files after the initial on?

Can you see anything wierd in your initial migration for the Product model?

here i can not see all methods in Product there is only 2 but I have those:

class Product(models.Model):
title:models.CharField(max_length=255)
slug: models.SlugField()
description:models.TextField()
price:models.DecimalField(max_digits=6,decimal_places=2)
inventory: models.IntegerField()
last_update: models.DateTimeField(auto_now=True)
collection: models.ForeignKey(Collection, on_delete=models.PROTECT)
promotions = models.ManyToManyField(Promotion, related_name=‘products’)

Hi,

Do you get a different result if you run this command:
python manage.py makemigrations store

And if you could please show a screenshot of the product model in models.py

no different result entered store or not

Hi YaPay,

I think the problem is that you’re defining your fields like this:

title: models.CharField(max_lenght=255)

You should define them like this (equal sign and not a colon):

title = models.CharField(max_lenght=255)

I changed the values with =

but now I am giving this error:

python3 manage.py makemigrations  3 ✘ 9s storefront-FK5d6ZFd Py
It is impossible to add a non-nullable field ‘collection’ to product without specifying a default. This is because the database needs something to populate existing rows.
Please select a fix:

  1. Provide a one-off default now (will be set on all existing rows with a null value for this column)
  2. Quit and manually define a default value in models.py.

meanwhile I followed 1:1 video course. In this course every model has been entered with : not =

Do you have any existing rows in your product table in your database? If not then I usually select option 1 and just enter a 1. Nothing will happen since you don’t have any rows to update.

The equal-sign-thingy is stated in lesson 5-Creating models aswell as the official documentation. If you’ve seen a field in a model being defined with a colon I think that is a mistake

link to model-documentation:

you are right I entered wrongly : but in video course every modal variable has got =

many thanks for your help but I would excpted the pyhton compiler warn me before