# \[GSoC 2021\] Adapt Schema Editors to operate from model states instead of fake rendered models

**URL:** <https://forum.djangoproject.com/t/gsoc-2021-adapt-schema-editors-to-operate-from-model-states-instead-of-fake-rendered-models/8012>\
**Category:** Google Season of Code\
**Created:** [May 22, 2021, 8:11am UTC](https://forum.djangoproject.com/t/gsoc-2021-adapt-schema-editors-to-operate-from-model-states-instead-of-fake-rendered-models/8012 "2021-05-22T08:11:55Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![manav014](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/manav014/32/2339_2.png) [@manav014](https://forum.djangoproject.com/u/manav014)\
**Post date:** [May 24, 2021, 11:29pm UTC](https://forum.djangoproject.com/t/gsoc-2021-adapt-schema-editors-to-operate-from-model-states-instead-of-fake-rendered-models/8012/3 "2021-05-24T23:29:55Z")

</div>

While writing the code for the central registry in ProjectState. I came across a problem which is mentioned below. I am trying to figure out the solution for the same. I would be glad if anyone may help me out with this.

# Problem

To initialize the central registry in `django.db.migrations.state.ProjectState.add_model` I need the following parameters

- from\_app\_label
- from model\_name
- from field
- to model\_name
- to app\_label
- to\_field

Out of all these required values I figured out how to get the first 5 values as follows:

- from\_app\_label - `model_State.app_label`
- from model\_name - `model_state.name_lower`
- from field - `model_state.fields.items()`
- to model\_name - `model_state.fields.items().field.remote_field.model`
- to app\_label - `model_state.fields.items().field.remote_field.model.split(".")`

But I am unable to figure out how can I get to\_field in case the to\_field is not explicitly defined by the developer.

Suggestions and feedback would be highly appreciated.

Regard,  
Manav

---

_[View the full topic](https://forum.djangoproject.com/t/gsoc-2021-adapt-schema-editors-to-operate-from-model-states-instead-of-fake-rendered-models/8012)._
