On Tue, Aug 2, 2011 at 1:02 PM, George Cummins <geo...@8people.com> wrote:
> On Tue, Aug 2, 2011 at 12:38 PM, Tom Evans <tevans...@googlemail.com>wrote: > >> On Tue, Aug 2, 2011 at 3:17 PM, George Cummins <geo...@8people.com> >> wrote: >> > While testing changes to an existing project, I disabled debugging. >> While >> > trying to restart the web server (uWSGI+nginix), I encountered the >> following >> > error: >> > >> > File "/opt/django-projects/preps/statistics/models.py", line 5, in >> <module> >> > >> > from preps.games.models import FootballGame, VolleyballGame, >> > GirlsBasketballGame, BoysBasketballGame, BaseballGame, SoftballGame >> > >> > ImportError: cannot import name VolleyballGame >> > >> > (Full traceback here: http://pastebin.com/AqzjTuLz) >> > The traceback I see at that linked page does not at all match the ImportError you report. What I see at the linked page is a traceback that ends with: File "/opt/django-projects/preps/../preps/statistics/models.py", line 196, in <module> class TeamVolleyballGame(models.Model): File "/opt/django-projects/preps/../preps/statistics/models.py", line 198, in TeamVolleyballGame game = models.ForeignKey(VolleyballGame) NameError: name 'VolleyballGame' is not defined Which is it -- NameEror or ImportError? > > This error does not occur when DEBUG=True, and does not occur when using >> > Django's runserver whether debugging is on or off. It only occurs when >> using >> > my production stack ( Django 1.2.5+uWSGI+nginx ). >> > [snip] >> > >> >> >> Django doesn't do anything differently, AFAIK (happy to be corrected). >> >> There are differences in import order with DEBUG on/off and also with runserver vs. production web server. When debug is on and a model is registered to the admin, the admin code includes a validation step ( https://code.djangoproject.com/browser/django/tags/releases/1.3/django/contrib/admin/validation.py) which fully loads all models. The runserver command similarly has a validation step (that is performed regardless of DEBUG setting) that can change the order in which files are imported compared to a production web server. These differences in import order can result in ImportErrors (and other errors) showing up only in certain environments. [snip] > In other places online, there are mentions of circular references causing > this type of problem. > I believe I have ruled out circular references as a problem, but the fact > that they are known > and ignored when debugging is enabled led me to believe there must be a > difference in the > load processes between debugging and non-debugging. > > If you could provide the full ImportError traceback someone might be able to help. Note these errors are not "ignored when debugging", rather DEBUG being on can cause the import order to be different so that certain problems don't manifest themselves. Karen -- http://tracey.org/kmt/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.