On 22/10/2015 10:40 PM, Christoph Knapp wrote:
> Hi,
> I have a legacy database and used "python manage.py inspectdb >
> models.py" to create a models.py file. After I modified the file all
> errors went away when I makemigrations. This step works without problems
> on the only app I have in my project. When I go "python manage.py
> migrate" I get the following error.
>
> Operations to perform:
> Â Synchronize unmigrated apps: staticfiles, messages
> Â Apply all migrations: admin, contenttypes, sessions, auth, readDatabase
> Synchronizing apps without migrations:
> Â Creating tables...
> Â Â Â Running deferred SQL...
> Â Installing custom SQL...
> Running migrations:
> Â Rendering model states... DONE
> Â Applying readDatabase.0001_initial...Traceback (most recent call last):
> Â File
> "/home/christoph_knapp/Bioinformatik/variantendatenbank_tool/manage.py",
> line 10, in <module>
> Â Â Â execute_from_command_line(sys.argv)
> Â File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
> line 351, in execute_from_command_line
> Â Â Â utility.execute()
> Â File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
> line 343, in execute
> Â Â Â self.fetch_command(subcommand).run_from_argv(self.argv)
> Â File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 394, in run_from_argv
> Â Â Â self.execute(*args, **cmd_options)
> Â File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 445, in execute
> Â Â Â output = self.handle(*args, **options)
> Â File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py",
> line 222, in handle
> Â Â Â executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
> Â File
> "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py",
> line 110, in migrate
> Â Â Â self.apply_migration(states[migration], migration, fake=fake,
> fake_initial=fake_initial)
> Â File
> "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py",
> line 148, in apply_migration
> Â Â Â state = migration.apply(state, schema_editor)
> Â File
> "/usr/local/lib/python2.7/dist-packages/django/db/migrations/migration.py",
> line 115, in apply
> Â Â Â operation.database_forwards(self.app_label, schema_editor,
> old_state, project_state)
> Â File
> "/usr/local/lib/python2.7/dist-packages/django/db/migrations/operations/models.py",
> line 59, in database_forwards
> Â Â Â schema_editor.create_model(model)
> Â File
> "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/schema.py",
> line 286, in create_model
> Â Â Â self.execute(sql, params or None)
> Â File
> "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/schema.py",
> line 111, in execute
> Â Â Â cursor.execute(sql, params)
> Â File
> "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py",
> line 79, in execute
> Â Â Â return super(CursorDebugWrapper, self).execute(sql, params)
> Â File
> "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py",
> line 64, in execute
> Â Â Â return self.cursor.execute(sql, params)
> Â File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py",
> line 97, in __exit__
> Â Â Â six.reraise(dj_exc_type, dj_exc_value, traceback)
> Â File
> "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py",
> line 62, in execute
> Â Â Â return self.cursor.execute(sql)
> django.db.utils.ProgrammingError: FEHLER: Relation „auth_group“
> existiert bereits
>
> The last line contains a little bit of German which translates into
> "Relation "auth_group" already exists". The auth_group table was
> generated by inspectdb and is none of the tables from the legacy
> database. The only change I made at those tables were that I removed the
> line "managed=False". When I put this back in I get the same error. The
> python code for the auth_group table is below.
>
> class AuthGroup(models.Model):
> Â Â Â name = models.CharField(unique=True, max_length=80)
>
> Â Â Â class Meta:
> Â Â Â Â Â Â Â db_table = 'auth_group'
auth_group is a Django table which you don't need to install. In your
models.py remove all models except your own, drop the database and try
again. The models/tables created for you by Django and the Admin are ...
auth_group
auth_group_permissions
auth_permission
auth_user
auth_user_groups
auth_user_user_permissions
django_admin_log
django_contenttype
django_migrations
django_session
Cheers
Mike
>
> I just started with django, so let me know whether you need anything else.
>
> Regards
>
> Christoph
>
> --
> 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
> <mailto:
django-users...@googlegroups.com>.
> To post to this group, send email to
django...@googlegroups.com
> <mailto:
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/a87703ec-cc25-4404-accf-e5cd800e23c7%40googlegroups.com
> <
https://groups.google.com/d/msgid/django-users/a87703ec-cc25-4404-accf-e5cd800e23c7%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit
https://groups.google.com/d/optout.