#31416: FieldError when migrating field to new model subclass.
-------------------------------+------------------------------------
Reporter: Eduard Anghel | Owner: Nan Liu
Type: Bug | Status: assigned
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Comment (by Nan Liu):
Replying to [comment:11 Sanskar Jaiswal]:
> >And I tried `model_state = self.to_state.models[base_app_label,
base_model_name]` to find `readable`'s fields, but there is only one field
left which is the self-generated `id` field. Not sure why the field
`title` is gone. I am pretty sure I am doing it wrong. But I am just
wondering if there are other ways to retrieve all fields from the base
class, which is `readable` in this case. much appreciated!
>
> Since we remove `title` from `Readable`, it doesn't show up in
`self.to_state.models[base_app_label, base_model_name]`. Doing this gives
you, the fields of our latest intended model, in which `Readable` is just
an empty model with one `AutoField` as the "self generated `id`." To get
the intended fields of `Readable`, you need to use
`self.from_state.models[base_app_label, base_model_name]` since
`from_state` refers to the previous state, i.e. in this case, just one
`Readable` model with a `CharField` named `title` (and the `id` of
course).
Hi Sanskar,
Thanks! I guess I should've done a better job at code reading :). I will
try it out today since I have an internship interview coming up in a few
hours! Much appreciated! I will keep u posted!
--
Ticket URL: <https://code.djangoproject.com/ticket/31416#comment:12>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/070.426a8a604f336b7d2ecf7b178e0a824e%40djangoproject.com.