from django.contrib.auth.models import User
class Agent(models.Model):
name = models.CharField(max_length=100)
users = models.ManyToManyField(User, related_name='accessible_agents',
default=[])
and when I have an empty database, and do python manage.py migrate.
It gives me error, and I tested on 1.7.8, it works fine.
Operations to perform:
Synchronize unmigrated apps: staticfiles, download, messages
Apply all migrations: admin, auth, contenttypes, sessions
Synchronizing apps without migrations:
Creating tables...
Creating table download_agent
Running deferred SQL...
Traceback (most recent call last):
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/django/db/backends/utils.py", line 62, in execute
return self.cursor.execute(sql)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/django/db/backends/mysql/base.py", line 124, in execute
return self.cursor.execute(query, args)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/MySQLdb/cursors.py", line 220, in execute
self.errorhandler(self, exc, value)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorvalue
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/MySQLdb/cursors.py", line 209, in execute
r = self._query(query)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/MySQLdb/cursors.py", line 371, in _query
rowcount = self._do_query(q)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/MySQLdb/cursors.py", line 335, in _do_query
db.query(q)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/MySQLdb/connections.py", line 280, in query
_mysql.connection.query(self, query)
_mysql_exceptions.OperationalError: (1005, "Can't create table
'portal_aperture.#sql-403_b3' (errno: 150)")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/django/core/management/__init__.py", line 338, in
execute_from_command_line
utility.execute()
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/django/core/management/base.py", line 393, in run_from_argv
self.execute(*args, **cmd_options)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/django/core/management/base.py", line 444, in execute
output = self.handle(*args, **options)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/django/core/management/commands/migrate.py", line 179, in handle
created_models = self.sync_apps(connection,
executor.loader.unmigrated_apps)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/django/core/management/commands/migrate.py", line 317, in
sync_apps
cursor.execute(statement)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/django/db/utils.py", line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/django/utils/six.py", line 658, in reraise
raise value.with_traceback(tb)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/django/db/backends/utils.py", line 62, in execute
return self.cursor.execute(sql)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/django/db/backends/mysql/base.py", line 124, in execute
return self.cursor.execute(query, args)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/MySQLdb/cursors.py", line 220, in execute
self.errorhandler(self, exc, value)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorvalue
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/MySQLdb/cursors.py", line 209, in execute
r = self._query(query)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/MySQLdb/cursors.py", line 371, in _query
rowcount = self._do_query(q)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/MySQLdb/cursors.py", line 335, in _do_query
db.query(q)
File "/srv/company/virtualenvs/portal_aperture/lib/python3.4/site-
packages/MySQLdb/connections.py", line 280, in query
_mysql.connection.query(self, query)
django.db.utils.OperationalError: (1005, "Can't create table
'portal_aperture.#sql-403_b3' (errno: 150)")
Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/25216>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/25216#comment:1>
Old description:
New description:
Hi,
I am using python version 3.4 and django 1.8.3, I have the following very
simple code:
from django.contrib.auth.models import User
class Agent(models.Model):
Thanks.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/25216#comment:2>
Comment (by cx44yale):
I suspect it is a problem with the order executed, the M2M expects my User
model.
I removed all of my models definition in that app, and run python
manage.py migrate to generate all those auth, sessions builtin tables, and
then paste my models back run migrate again, this time everything works,
and all the tables are generated correctly.
Thanks
--
Ticket URL: <https://code.djangoproject.com/ticket/25216#comment:3>
Old description:
> Hi,
> I am using python version 3.4 and django 1.8.3, I have the following very
New description:
Hi,
I am using python version 3.4 and django 1.8.3, I have the following very
class Agent(models.Model):
--
--
Ticket URL: <https://code.djangoproject.com/ticket/25216#comment:4>
Old description:
> Hi,
> I am using python version 3.4 and django 1.8.3, I have the following very
New description:
Hi,
I am using python version 3.4 and django 1.8.3, I have the following very
simple code:
{{{
from django.contrib.auth.models import User
class Agent(models.Model):
name = models.CharField(max_length=100, primary_key=True)
--
--
Ticket URL: <https://code.djangoproject.com/ticket/25216#comment:5>
Comment (by timgraham):
Did you create migrations for your app using `makemigrations`? If not, you
have an unmigrated app depending on a migrated one as described
[https://docs.djangoproject.com/en/1.8/topics/migrations/#dependencies in
the docs] which is an invalid configuration.
--
Ticket URL: <https://code.djangoproject.com/ticket/25216#comment:6>
* status: new => closed
* resolution: => needsinfo
Comment:
Please reopen with a sample project to reproduce the problem if my last
comment is incorrect. Thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/25216#comment:7>