[Django] #23255: Migrations fail with custom models.Field

5 views
Skip to first unread message

Django

unread,
Aug 7, 2014, 8:26:41 AM8/7/14
to django-...@googlegroups.com
#23255: Migrations fail with custom models.Field
---------------------------------+----------------------
Reporter: django@… | Owner: nobody
Type: Uncategorized | Status: new
Component: Migrations | Version: 1.7-rc-2
Severity: Release blocker | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+----------------------
Follow the example at https://docs.djangoproject.com/en/dev/howto/custom-
model-fields/#writing-a-field-subclass

and try to run `./manage.py migrate`

The following exception is given:

{{{
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/patrick/.virtualenvs/migr/lib/python2.7/site-
packages/django/core/management/__init__.py", line 385, in
execute_from_command_line
utility.execute()
File "/Users/patrick/.virtualenvs/migr/lib/python2.7/site-
packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/patrick/.virtualenvs/migr/lib/python2.7/site-
packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/patrick/.virtualenvs/migr/lib/python2.7/site-
packages/django/core/management/base.py", line 337, in execute
output = self.handle(*args, **options)
File "/Users/patrick/.virtualenvs/migr/lib/python2.7/site-
packages/django/core/management/commands/migrate.py", line 153, in handle
ProjectState.from_apps(apps),
File "/Users/patrick/.virtualenvs/migr/lib/python2.7/site-
packages/django/db/migrations/state.py", line 104, in from_apps
model_state = ModelState.from_model(model)
File "/Users/patrick/.virtualenvs/migr/lib/python2.7/site-
packages/django/db/migrations/state.py", line 181, in from_model
e,
TypeError: Couldn't reconstruct field field1 on migr2.MyModel: __init__()
got multiple values for keyword argument 'verbose_name'
}}}

See my example project at
https://github.com/pjrobertson/django_migrations_bug2
and run `./manage.py migrate` to reproduce

--
Ticket URL: <https://code.djangoproject.com/ticket/23255>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 7, 2014, 8:38:30 AM8/7/14
to django-...@googlegroups.com
#23255: Migrations fail with custom models.Field
---------------------------------+--------------------------------------
Reporter: django@… | Owner: nobody
Type: Uncategorized | Status: closed
Component: Migrations | Version: 1.7-rc-2
Severity: Release blocker | Resolution: worksforme
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by bmispelon):

* status: new => closed
* needs_better_patch: => 0
* resolution: => worksforme
* needs_tests: => 0
* needs_docs: => 0


Comment:

Hi,

Your code incorrectly passes `self` when calling the `super(...)` in
`__init__`:
{{{#!python
super(MyField, self).__init__(self, *args, **kwargs)
}}}

Should be:
{{{#!python
super(MyField, self).__init__(*args, **kwargs)
}}}

(as is documented)

Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/23255#comment:1>

Reply all
Reply to author
Forward
0 new messages