Wednesday, April 29, 2015

RemovedInDjango19Warning: Model class %s doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS ..

I am trying to understand this warning better. I understand that we want to make sure that a model has an explicit app_label or it is in INSTALLED_APPS. I spent some time trying to remove warnings from my code because I was getting these warning messages even though my model was defined in an app listed in INSTALLED_APPS. 

After scratching my head for quite some time, I put a breakpoint on the following line of the code in django.db.models.base:



# Look for an application configuration to attach the model to.

app_config = apps.get_containing_app_config(module)


And I checked to see what I get for "app_configs.values()" and I realized that the app is in INSTALLED_APPS but not yet been loaded. This was because one of the third party framework I use was trying to import models before they were loaded. 

My question is the following:

Is Django trying to prevent a model from being imported before this model is actually defined? If this is the case, is it possible to improve the warning so that it would check "INSTALLED_APPS" and warn the user that even if the app is listed there some other app is trying to import the model before the app is loaded?"

If the intention is not as aforementioned, is this a bug?

Thank you

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ea782849-8c6a-48b1-92e2-1cdfabf15c4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment