I attached a sample app here. You need to install django-haystack prior to running the app. haystack lets you define "Haystack Signal Processor". and in this signal processor, it attempts to load one of the models that belong to an app that is listed in INSTALLED_APPS after haystack. I would appreciate it if you could review this and see if it is a legit bug.. I will be more than happy to create a ticket for it.
-- Thank you
On Wednesday, April 29, 2015 at 3:14:34 PM UTC-7, Carl Meyer wrote:
On Wednesday, April 29, 2015 at 3:14:34 PM UTC-7, Carl Meyer wrote:
Hi,
On 04/29/2015 11:13 AM, Bumyong Choi wrote:
> 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?"
Yes, that is the current intention in Django 1.7+: you may not import a
models.py file before the app cache has been prepared. (I personally
think this is unfortunate, but to change it while maintaining consistent
and predictable semantics would require a deep reworking of how relation
fields are initialized, which nobody has so far attempted).
I'm surprised you are getting that particular error though - if a
models.py file is imported too soon, I would expect an "App registry not
ready" error instead. So it may be a bug that you are getting this error
message instead of that one; hard to know without seeing code to
reproduce the issue.
Carl
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/233ad1eb-cb9a-465f-9df6-f68934a96218%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment