[Django] #25765: makemigrations and app_label are incompatible

18 views
Skip to first unread message

Django

unread,
Nov 16, 2015, 4:35:30 PM11/16/15
to django-...@googlegroups.com
#25765: makemigrations and app_label are incompatible
-------------------------------+--------------------
Reporter: ograycode | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
Repo steps:

* Create a new app called "testapp"
* Add one model to the models.py with a meta class and app_label which
are different then your current one.
* Run "manage.py makemigrations testapp"

On the third step, it will state that there are no changes. If you remove
the custom app_label and run makemigrations again it will pick up on the
new model. If you change app_label once again, it will see that as a
deletion of the model.

I believe that it should either be explicitly documented, or that
app_label should have no bearing on makemigrations.

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

Django

unread,
Nov 16, 2015, 6:34:57 PM11/16/15
to django-...@googlegroups.com
#25765: makemigrations and app_label are incompatible
--------------------------------------+------------------------------------
Reporter: ograycode | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.8
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
--------------------------------------+------------------------------------
Changes (by knbk):

* needs_better_patch: => 0
* component: Uncategorized => Documentation
* needs_tests: => 0
* needs_docs: => 0
* type: Uncategorized => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

The behaviour is correct. By changing the `app_label`, you are effectively
moving the model to a different app without changing the file location. If
the new app label is the label of a valid Django app, you will be able to
create migrations for that model using the explicitly defined `app_label`.

Django currently does not support moving a model from one application to
another. That's why it sees the model as a new model when you remove the
explicit app label, and sees it as a deleted model when you change the app
label again. The new app label you define is not recognized as a valid
app, so it is treated as an unmigrated app (or the model might be ignored
by `manage.py migrate` - something to figure out as well).

We can expand the description of
[https://docs.djangoproject.com/en/1.8/ref/models/options/#app-label
Meta.app_label] and link to
[https://docs.djangoproject.com/en/1.8/ref/applications/#django.apps.AppConfig.label
AppConfig.label] to clarify that changing the `app_label` also changes the
app in which the model lives according to Django. The django-admin page
has a [https://docs.djangoproject.com/en/1.8/ref/django-admin/#app-names
short section] about the "app name" used by various commands. I suggest we
change the terminology to app label to clarify its meaning and be
consistent with the rest of the documentation. This section could also be
a bit more elaborate.

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

Django

unread,
Nov 30, 2015, 4:36:06 AM11/30/15
to django-...@googlegroups.com
#25765: makemigrations and app_label are incompatible
-------------------------------------+-------------------------------------
Reporter: ograycode | Owner: tgmiller5
Type: | Status: assigned
Cleanup/optimization |

Component: Documentation | Version: 1.8
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
-------------------------------------+-------------------------------------
Changes (by tgmiller5):

* owner: nobody => tgmiller5
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/25765#comment:2>

Django

unread,
Aug 18, 2016, 7:43:42 PM8/18/16
to django-...@googlegroups.com
#25765: makemigrations and app_label are incompatible
--------------------------------------+------------------------------------
Reporter: ograycode | Owner:
Type: Cleanup/optimization | Status: new

Component: Documentation | Version: 1.8
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
--------------------------------------+------------------------------------
Changes (by timgraham):

* status: assigned => new
* owner: tgmiller5 =>


--
Ticket URL: <https://code.djangoproject.com/ticket/25765#comment:3>

Django

unread,
Aug 10, 2023, 8:31:08 AM8/10/23
to django-...@googlegroups.com
#25765: makemigrations and app_label are incompatible
--------------------------------------+------------------------------------
Reporter: ograycode | Owner: nobody

Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.8
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
--------------------------------------+------------------------------------
Changes (by Sarah Boyce):

* cc: Bhuvnesh (added)


Comment:

Hi Bhuvnesh! I just saw this ticket and thought that your GSoC project of
moving models between apps is quite related. Would this need to be closed
once your PR is accepted or would the documentation still be valid?

--
Ticket URL: <https://code.djangoproject.com/ticket/25765#comment:2>

Django

unread,
Aug 10, 2023, 9:37:30 AM8/10/23
to django-...@googlegroups.com
#25765: makemigrations and app_label are incompatible
--------------------------------------+------------------------------------
Reporter: ograycode | Owner: nobody

Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.8
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 Bhuvnesh):

Hi Sarah! Once My PR is accepted, this ticket can be closed. Changing the
app_label or actually moving the model to other app generates exactly the
same migrations. So i don't think we would need to document this.
(I'll add this case in my [https://github.com/DevilsAutumn/moving-model-
demo demo project ] too.)

--
Ticket URL: <https://code.djangoproject.com/ticket/25765#comment:3>

Django

unread,
Aug 18, 2023, 3:35:40 PM8/18/23
to django-...@googlegroups.com
#25765: makemigrations and app_label are incompatible
--------------------------------------+------------------------------------
Reporter: ograycode | Owner: Bhuvnesh
Type: Cleanup/optimization | Status: assigned

Component: Documentation | Version: 1.8
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
--------------------------------------+------------------------------------
Changes (by Bhuvnesh):

* owner: nobody => Bhuvnesh


* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/25765#comment:4>

Reply all
Reply to author
Forward
0 new messages