Getting NameError with Django 1.5 and IPython

I am running Django 1.5.1, Python 2.7.2 and IPython 0.13.2. If I use "python./manage.py shell" from my Django project directory, I get the following error:

from django import forms
class CommentForm(forms.Form):
    name = forms.CharField()

NameError: name 'forms' is not defined.

I know that forms are defined as I can see it when it does "dir (forms)". I noticed that this error only occurs when I run iPython in REPL. If I run REPL and use only the plain, old Python interpreter, an error does not occur.

Has anyone else experienced this issue? If so, do you know why this is happening, and is there work?

I have to add that in the past I had problems creating classes in REPL until I created a metaclass in the class and defined the variable "app_label". This did not affect the situation.

Thank.

+5
source share
1 answer

django 1.5 does not start IPython correctly. This is fixed in the main , but the fix was not addressed to 1.5.1. If you manually apply this patch to core / management / commands / shell.py, IPython should work as expected.

+8
source

All Articles