Opened 8 years ago
Closed 8 years ago
#27114 closed Bug (invalid)
Migrations: AttributeError: can't set attribute
Reported by: | sweaver360 | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 1.10 |
Severity: | Normal | Keywords: | AttributeError Migrations 1.10 |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I just updated to Django 1.10 from Django 1.9.9, and when I ran my server it told me I needed to migrate due to a change in auth. When I ran manage.py migrate, I get the following error:
vagrant@vagrant-box:~/website$ python manage.py migrate System check identified some issues: WARNINGS: ?: (mysql.W002) MySQL Strict Mode is not set for database connection 'default' HINT: MySQL's Strict Mode fixes many data integrity problems in MySQL, such as data truncation upon insertion, by escalating warnings into errors. It is strongly recommended you activate it. See: https://docs.djangoproject.com/en/1.10/ref/databases/#mys ql-sql-mode myapp.MyModel.my_field: (fields.W901) CommaSeparatedIntegerField has been deprecated. Support for it (except in historical migrations) will be removed in Django 2.0. HINT: Use CharField(validators=[validate_comma_separated_integer_list]) instead. Operations to perform: Apply all migrations: [...] Running migrations: Traceback (most recent call last): File "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 367, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 359, 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 305, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 356, in execute output = self.handle(*args, **options) File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 202, in handle targets, plan, fake=fake, fake_initial=fake_initial File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 97, in migrate state = self._migrate_all_forwards(plan, full_plan, fake=fake, fake_initial=fake_initial) File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 138, in _migrate_all_forwards migration.mutate_state(state, preserve=False) File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/migration.py", line 92, in mutate_state operation.state_forwards(self.app_label, new_state) File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/operations/models.py", line 733, in state_forwards state.reload_model(app_label, self.name_lower) File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/state.py", line 162, in reload_model self.apps.render_multiple(states_to_be_rendered) File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/state.py", line 277, in render_multiple model.render(self) File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/state.py", line 559, in render body, File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 157, in __new__ new_class.add_to_class(obj_name, obj) File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 316, in add_to_class value.contribute_to_class(cls, name) File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 120, in contribute_to_class setattr(model, name, ManagerDescriptor(self)) AttributeError: can't set attribute
As far as I could tell, the code in the stack trace is all Django code, so I don't think it's a bad site package. Is it possible that something in my code needs to change to prevent this error, or is this a Django bug? Thanks.
Change History (6)
follow-up: 2 comment:1 by , 8 years ago
comment:2 by , 8 years ago
Replying to timgraham:
Can you provide a minimal project that reproduces the issue? We can't do much to diagnose the issue based on the stacktrace alone.
I'm guessing it won't happen if I just start a new Django 1.10 project since no one else is reporting the issue, which makes me think it's probably something in my project. Is there any way to find out which migration is causing the exception? It's hard to tell what's going on with it only referencing core Django files in the stack trace.
comment:3 by , 8 years ago
You can edit /usr/local/lib/python2.7/dist-packages/django/db/models/manager.py
and add some print statements to see the relevant model that's causing the exception. The idea of a minimal project would be to strip down your current project to something that you can share.
follow-up: 5 comment:4 by , 8 years ago
There was a similar error with django-mptt <= 0.8.5, are you using django-mptt or any other third party app?
comment:5 by , 8 years ago
Replying to claudep:
There was a similar error with django-mptt <= 0.8.5, are you using django-mptt or any other third party app?
Thanks for the help, it looks like the issue is django-mptt. I just upgraded to 0.8.6 (I was unable to even run a server when I was on 0.8.5). When I added print statements to django/db/models/manager.py, the model causing the issue is my model that inherits from MPTTModel. I'll follow up with them to work through this issue.
Thanks again.
comment:6 by , 8 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Can you provide a minimal project that reproduces the issue? We can't do much to diagnose the issue based on the stacktrace alone.