Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#23439 closed Bug (worksforme)

./manage.py makemigrations fail on 3.4.1 but works on 2.7.6

Reported by: DanGamble89 Owned by: nobody
Component: Python 3 Version: 1.7
Severity: Normal Keywords: manage.py migrations
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 have 2 virtualenvs one running 2.7.6 and one running 3.4.1 i had just added some fields to a model, nothing out of the ordinary just IntegerFields. I went to run the makemigrations command and got this error:

(fifautdb)@Dans ➜  fifautdb git:(master) ✗ ./manage.py makemigrations
Traceback (most recent call last):
  File "./manage.py", line 19, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/dangamble/Envs/fifautdb/lib/python3.4/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/Users/dangamble/Envs/fifautdb/lib/python3.4/site-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/dangamble/Envs/fifautdb/lib/python3.4/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Users/dangamble/Envs/fifautdb/lib/python3.4/site-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/Users/dangamble/Envs/fifautdb/lib/python3.4/site-packages/django/core/management/commands/makemigrations.py", line 111, in handle
    convert_apps=app_labels or None,
  File "/Users/dangamble/Envs/fifautdb/lib/python3.4/site-packages/django/db/migrations/autodetector.py", line 40, in changes
    changes = self._detect_changes(convert_apps, graph)
  File "/Users/dangamble/Envs/fifautdb/lib/python3.4/site-packages/django/db/migrations/autodetector.py", line 107, in _detect_changes
    self.old_apps = self.from_state.render(ignore_swappable=True)
  File "/Users/dangamble/Envs/fifautdb/lib/python3.4/site-packages/django/db/migrations/state.py", line 67, in render
    model.render(self.apps)
  File "/Users/dangamble/Envs/fifautdb/lib/python3.4/site-packages/django/db/migrations/state.py", line 311, in render
    body,
  File "/Users/dangamble/Envs/fifautdb/lib/python3.4/site-packages/django/db/models/base.py", line 171, in __new__
    new_class.add_to_class(obj_name, obj)
  File "/Users/dangamble/Envs/fifautdb/lib/python3.4/site-packages/django/db/models/base.py", line 300, in add_to_class
    value.contribute_to_class(cls, name)
  File "/Users/dangamble/Envs/fifautdb/lib/python3.4/site-packages/django/db/models/fields/related.py", line 1572, in contribute_to_class
    super(ForeignObject, self).contribute_to_class(cls, name, virtual_only=virtual_only)
  File "/Users/dangamble/Envs/fifautdb/lib/python3.4/site-packages/django/db/models/fields/related.py", line 264, in contribute_to_class
    'app_label': cls._meta.app_label.lower()
TypeError: unsupported operand type(s) for %: 'bytes' and 'dict'

When i ran it in the 2.7.6 venv it make the migrations fine, it also gave the error when running the migrate command

Change History (5)

comment:1 by Tim Graham, 10 years ago

We need more details like a test for Django's test suite or a minimal project with steps to reproduce the error. Thanks!

comment:2 by Baptiste Mispelon, 10 years ago

Looking at where the error is triggered, it seems that you've defined a related_name as a bytestring somewhere in your code.

Could you show your model definitions?

Thanks.

in reply to:  2 comment:3 by DanGamble89, 10 years ago

Hey it did seem like it created a duplicate migration or it tried running a migration that was already ran. Not sure why the 2.7.6 version didn't seem to spit up any errors. I guess this is 'sorted' per-se as it seemed like i was trying to do something it already had done!

Replying to bmispelon:

Looking at where the error is triggered, it seems that you've defined a related_name as a bytestring somewhere in your code.

Could you show your model definitions?

Thanks.

comment:4 by DanGamble89, 10 years ago

Resolution: fixed
Status: newclosed

comment:5 by Collin Anderson, 10 years ago

Resolution: fixedworksforme
Note: See TracTickets for help on using tickets.
Back to Top