Friday, September 7, 2018

Re: models.py => Mandatory to create tables?

So the models directory should look like this:
__init__.py
model1.py

In the __init__.py file you should have the following:
from .model1 import Model1

Then it should "just work".

Regards

Andréas


Den fre 7 sep. 2018 kl 16:35 skrev Benjamin SOULAS <benjamin.soulas45@gmail.com>:
Ok, so I think I really have a much deeper problem, __init__.py file are there, nothing still happen 

Le vendredi 7 septembre 2018 16:31:01 UTC+2, Andréas Kühne a écrit :
If you follow the way Mike suggests - migrations will work (this is the way we do it in our plattform). The important thing is that you MUST have a models.py file OR a models module (a directory with the name models and a __init__.py file with the imports from the individual files).

Regards,

Andréas


Den fre 7 sep. 2018 kl 16:27 skrev Benjamin SOULAS <benjamin...@gmail.com>:
Hi Mike (again !),

Okay, but it seems I have a much deeper problem, nothing happens during make migration command, I am thinking on deleting my db and restart from scratch ...

Thanks ! 

Le vendredi 7 septembre 2018 16:25:21 UTC+2, Mike Dewhirst a écrit :
Easy

Create a models directory. In there make __init__.py file and in there ...

from .whatever import Whatever
... 100 classes

Then in ./models create 100 files with one model class in each file

Anywhere in the project you can say ...

from app.models import Whatever



Connected by Motorola


Benjamin SOULAS <benjamin...@gmail.com> wrote:

Hi everyone,

Quick question I do not find the answer: does models have to located into models.py script? It believe not, If I got a project composed of 100 tables, it's weird to me that all models should be located here ...

I tried, in this file, to import a model located somewhere else, but when i run python manage.py makemigrations, nothing happens, any idea?

Kind regards

Benjamin

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a4da5a12-9c9b-42b6-b295-5492658cb046%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/65c0b624-886c-46f7-9776-91971564d8d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4298cf98-cad3-413d-a7bc-2a8e587b2ba2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK4qSCdbOBWuKAQ51byWRhoXqtxmjjqYb%3D91VjXkpwQQf63JGw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment