#21215: Migrations for inherited models
----------------------------+----------------------------------------
Reporter: anant90@… | Owner:
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Keywords: migrations inherited model
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+----------------------------------------
I have a model BankAccount which inherits from another model PaymentType
as shown below:
{{{
class PaymentType(BaseModel):
user = models.ForeignKey(StupaUser, related_name =
"%(app_label)s_%(class)s_related")
class BankAccount(PaymentType):
account_number = models.CharField(max_length=20)
bank_name = models.CharField(max_length=40)
nickname = models.CharField(max_length=30)
uri = models.CharField(max_length=200, null=True)
is_valid = models.BooleanField(default=True)
}}}
When I try running python manage.py makemigrations <app_name>, I get
"ValueError: No field called user on model BankAccount"
Here's the stack trace:
{{{
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/anant/Github/django/django/core/management/__init__.py",
line 397, in execute_from_command_line
utility.execute()
File "/Users/anant/Github/django/django/core/management/__init__.py",
line 390, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/anant/Github/django/django/core/management/base.py", line
242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/anant/Github/django/django/core/management/base.py", line
289, in execute
output = self.handle(*args, **options)
File
"/Users/anant/Github/django/django/core/management/commands/makemigrations.py",
line 52, in handle
changes = autodetector.changes(graph=loader.graph,
trim_to_apps=app_labels or None)
File "/Users/anant/Github/django/django/db/migrations/autodetector.py",
line 34, in changes
changes = self._detect_changes()
File "/Users/anant/Github/django/django/db/migrations/autodetector.py",
line 140, in _detect_changes
field = model_state.get_field_by_name(field_name),
File "/Users/anant/Github/django/django/db/migrations/state.py", line
177, in get_field_by_name
raise ValueError("No field called %s on model %s" % (name, self.name))
ValueError: No field called user on model BankAccount
}}}
Is this expected? Why can't I use migrations for inherited models?
--
Ticket URL: <https://code.djangoproject.com/ticket/21215>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/060.c244f55ff0d2007990a5e698c32fbf9c%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.