0

I'm new to python and django, I'm creating a simple shopping app. I have followed all the steps to create django rest-framework project, run the server and it works. What I did is created a new folder called Models (deleted the pre-defined models.py) and created inside it many model classes in addition of an __init__.py file as I red and imported all the classes inside it.

When running python manage.py makemigrations it return ''No changes detected''.

Here is the structure:

quickstart/

 .
 . 

`Models/
      __init__.py
      model1.py
      model2.py
         .
         .
         .

tutorial/

manage.py

Here is a created class:

from django.db import models
from quickstart.Models.Product import Product
    class Image (models.Model):
        id = models.IntegerField(primary_key=True, auto_created=True)
        product = models.ForeignKey(Product, on_delete=models.CASCADE)
        image_url = models.TextField()
Omar Fayad
  • 1,733
  • 3
  • 11
  • 27

2 Answers2

0

try giving app name while migrating python manage.py makemigrations app_name

Shashikamal R C
  • 512
  • 3
  • 8
  • 1
    Welcome to SO Shashikamal. I'm sorry, this is not even remotely an adequate answer. This would be better suited as a comment. However, whenever you are just guessing solutions, always explain, what you try to do, not only say what to execute. – Aiyion.Prime Mar 22 '20 at 09:51
0

include in models.py

a picture says a lot. If you name the file straight as models it will work straight, but if you want to use custom name like models_1.py make sure you import it in __init__.py file.

include in custom models file

This is a brief read.

M.A.K. Simanto
  • 634
  • 1
  • 7
  • 20