From 38b8d180917ec4eaf3f12618d9114e08e3fad586 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Thu, 1 Dec 2005 06:09:36 +0000 Subject: [PATCH] Fixed #965 -- 'django-admin.py sqlsequencereset' now includes m2m tables. Thanks for reporting, exoweb adrian git-svn-id: http://code.djangoproject.com/svn/django/trunk@1517 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/management.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/django/core/management.py b/django/core/management.py index e474072e83..d14c97b568 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -238,6 +238,9 @@ def get_sql_sequence_reset(mod): output.append("SELECT setval('%s_%s_seq', (SELECT max(%s) FROM %s));" % \ (klass._meta.db_table, f.column, db.db.quote_name(f.column), db.db.quote_name(klass._meta.db_table))) + for f in klass._meta.many_to_many: + output.append("SELECT setval('%s_id_seq', (SELECT max(%s) FROM %s));" % \ + (f.get_m2m_db_table(klass._meta), db.db.quote_name('id'), f.get_m2m_db_table(klass._meta))) return output get_sql_sequence_reset.help_doc = "Prints the SQL statements for resetting PostgreSQL sequences for the given model module name(s)." get_sql_sequence_reset.args = APP_ARGS