On Mon, Jan 26, 2009 at 8:03 AM, phoebebright <[email protected]>wrote:
>
> Am I blind?
>
> I am getting this error in the shell, but no obvious errors when using
> the browser interface.
>
> >>> from models import Business
> Traceback (most recent call last):
> File "<console>", line 1, in ?
> File "/home/django/towns/models.py", line 8, in ?
> class Category(models.Model):
> File "/usr/lib/python2.4/site-packages/django/db/models/base.py",
> line 51, in __new__
> kwargs = {"app_label": model_module.__name__.split('.')[-2]}
> IndexError: list index out of range
>
Normally I'd expect "from models import Whatever" from manage.py shell to to
give me an "ImportError: No module named models". The fact that yours
doesn't implies you've either got a models.py file in the same directory as
your settings.py or you've put an individual app directory on your
PYTHONPATH. Neither seems like a particularly good idea. Instead use:
>>> from appname.models import Business
(where 'appname' is replaced with your actual app name) and then you won't
get an error when Django tries to figure out the app label associated with
the model.
Karen
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---