Does Django detect changes in models Meta ?

523 views
Skip to first unread message

termopro

unread,
Aug 22, 2014, 3:32:43 AM8/22/14
to django...@googlegroups.com
Hi there,

I am using Django 1.7 RC2.
I have created models and have run all the migrations so Django created tables in database.
Now i decided to change database table names and have added Meta class to models containing table name:

class SomeModel(models.Model):
   ...
   class Meta:
      db_table = 'newname'

Now when i run "makemigrations" Django doesn't detect any changes in models:
"No changes detected in app 'blabla'."
As far as i understand the logic, Django should change table names from 'appname_somemodel" to "newname".

Is this an expected behavior or i am missing something?

Norman Bird

unread,
Aug 22, 2014, 9:55:07 AM8/22/14
to django...@googlegroups.com
I am new, just completed the tutorials, but from my understanding you run "python manage.py syncdb" and that rebuilds the tables etc.  

Néstor

unread,
Aug 22, 2014, 11:08:26 AM8/22/14
to django...@googlegroups.com
is that true if the table is already there?


--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1083dee2-e8ec-451f-9ef9-1ebbc04c41af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Norman Bird

unread,
Aug 22, 2014, 11:41:00 AM8/22/14
to django...@googlegroups.com
I believe so. Wont hurt to try it and see what happens.


--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/Yj6Guv0ch5k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

For more options, visit https://groups.google.com/d/optout.



--
Thank You,

Norman Bird
Principal Web Development Consultant
DatabaseInDays.com
(703) 986-7157

Larry Martell

unread,
Aug 22, 2014, 11:47:47 AM8/22/14
to django...@googlegroups.com
On Fri, Aug 22, 2014 at 9:55 AM, Norman Bird <steelp...@gmail.com> wrote:
> I am new, just completed the tutorials, but from my understanding you run
> "python manage.py syncdb" and that rebuilds the tables etc.

No, syncdb only create tables that do not exist. It does not alter any
existing tables.

Norman Bird

unread,
Aug 22, 2014, 11:50:08 AM8/22/14
to django...@googlegroups.com
I stand corrected. :-) 


--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/Yj6Guv0ch5k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

For more options, visit https://groups.google.com/d/optout.

Norman Bird

unread,
Aug 22, 2014, 11:42:33 PM8/22/14
to django...@googlegroups.com
how about: python manage.py sql myapp 
I just changed my model and I had to runt that in order to build the tables. 

David Los

unread,
Sep 2, 2014, 4:16:45 PM9/2/14
to django...@googlegroups.com
Very, very good question. I am experiencing the same issues with Django 1.7rc2 and 1.7rc3.

Syncdb and sql statements are intended for Django < 1.7.

Would love to hear a solution!

Op vrijdag 22 augustus 2014 09:32:43 UTC+2 schreef termopro:

Malik Rumi

unread,
Sep 7, 2014, 11:54:39 AM9/7/14
to django...@googlegroups.com
Django 1.7rc2 here. Same question, same hope for an answer. It may be that not all possible changes to a model are intended to be picked up. For example, I created all my models directly in 1.7rc2, and I have not changed any fields. What I have done is changed / added some meta and methods. Maybe these changes don't 'count'? 

Your models will be scanned and compared to the versions currently contained in your migration files, and then a new set of migrations will be written out. Make sure to read the output to see what makemigrations thinks you have changed - it’s not perfect, and for complex changes it might not be detecting what you expect.

and

Migrations are Django’s way of propagating changes you make to your models (adding a field, deleting a model, etc.)

 So it might be that unless you change something that actually hits the database, there won't be anything to migrate, and that makes sense, but it would be nice if someone with expertise, experience, and inside knowledge could confirm and explain that. 

Michael A. Martin

unread,
Sep 8, 2014, 10:38:42 AM9/8/14
to django...@googlegroups.com
Maybe Migrations is just really buggy? I am using PostgreSQL as the backend. I added a column with a default value and then did makemigrations then migrate. It doesn't work. I get a very long error.
--
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 http://groups.google.com/group/django-users.

Malik Rumi

unread,
Sep 8, 2014, 11:37:15 AM9/8/14
to django...@googlegroups.com
>>Maybe Migrations is just really buggy? I am using PostgreSQL as the backend. I added a column with a default value and then did makemigrations then migrate. It doesn't work. I get a very long error<<

hmmmm...... I hope not. I'm using Postgres too. Looks like I'll have to add a new field to my models tonight when I get off work from the day job. I'll let you know what happens.

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/Yj6Guv0ch5k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages