Sunday, March 31, 2013

Re: Hey! I'm recieving an index error when trying to import models, and I can't figure out why.

When importing Python modules, you don't need to include the '.py' file extension. So,
from models.py import UUID
...needs to be:
from models import UUID

Hope this helps,
Jonathan


On Sun, Mar 31, 2013 at 10:27 PM, C Alaric Moore <alaricmeister@gmail.com> wrote:
Hello,

I am incredibly new to Django, as-of-today new, so forgive me if I've missed something really obvious.

I've been going through the tutorial and did so mostly-successfully and decided to redo it with my own code.

Everything was going fine until I decided that it would be a good idea to type from models.py import UUID, Students into the shell. With this I received the following error:

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/django/db/models/base.pyc in __new__(cls, name, bases, attrs)
     90             # For 'django.contrib.sites.models', this would be 'sites'.

     91             model_module = sys.modules[new_class.__module__]
---> 92             kwargs = {"app_label": model_module.__name__.split('.')[-2]}
     93         else:
     94             kwargs = {}

IndexError: list index out of range

I went onto stackoverflow and found some people had similar issues a year ago, and suggested that a person delete the pyc files, which I did. It was also suggested that you make DEBUGGING = False, or True or whatever is opposite. I did this, too, only to find the same error.

I did some other things too, all to no avail... all the same error. I even checked to make sure I was saving edited files, TWICE. Still, same error.

With this, I ask for your help o' wise ones.

Thanks.


--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Jonathan D. Baker
Developer
http://jonathandbaker.com

--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment