Migrations for forms fields

31 views
Skip to first unread message

Pranjal Tale

unread,
Aug 15, 2016, 6:56:41 PM8/15/16
to Django users
Hello!
I was writing my models with forms.Forms and after writing when i run "python manage.py makemigrations app_label" it shows the error as "app not deceted".

And at at same time when i build some models with models.Model and when i run the same command so all the migrations get implemented.

It is so that for forms based models migrations are not applied
If not i am unable to find the bug
Please Help
Thanks.  

Gergely Polonkai

unread,
Aug 16, 2016, 3:14:27 AM8/16/16
to Django users

Hello,

rename migrations in your head to database migrations, or even model to database migrations.

The migration process takes all your models and applies all the changes in them to your database (usually an SQL instance in the wild).

Forms, on the other hand, are just that: forms, that can get some input from somewhere. Although they can be used to interact with models (in fact, there is ModelForm designed specifically for this case), they are not models, thus, migrations don't apply to them.

Hope that makes the picture clear.

Best,
Gergely


--
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/f2b8c7cb-4e9c-4543-a80c-65d5bee3d935%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ludovic coues

unread,
Aug 16, 2016, 4:52:56 PM8/16/16
to django...@googlegroups.com
forms.Form are python class representing an HTML form. You use them to
ask data to your user. Nothing more.

models.Model are python class representing an entry in your database.
You create them in python, always.

Sometimes, you use a form by itself. For exemple, a login form will
ask data, search a user matching these data and log you in if a user
is found.

Sometimes, you use a form to create an object. A signup form for
exemple. You will use a form to ask data then create a user object
with the data.

But even in this last exemple, the form object isn't related to the
models object, in the sense each one can live without the other and
have (nearly) non-overlapping role. The form object don't touch the
database and the model object don't provide a form.


I'm not sure I am being clear enough so don't hesitate to ask question.
> https://groups.google.com/d/msgid/django-users/CACczBUK-iZkH3u_KSYkT%2B%2BO2e2%3D8ckzBk6KegSC0uQeYTwv-5Q%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.



--

Cordialement, Coues Ludovic
+336 148 743 42
Reply all
Reply to author
Forward
0 new messages