http://translate.google.com/#auto|en|%20list%20index%20out%20of%20range

On Dec 21, 6:10 pm, Bill Freeman <ke1g...@gmail.com> wrote:
> On Tue, Dec 21, 2010 at 5:53 PM, Jonathan Hayward <
>
>
>
>
>
> christos.jonathan.hayw...@gmail.com> wrote:
> > [jhayw...@cmlnxbld01 invdb]$ python manage.py shell
> > Python 2.7 (r27:82500, Dec  2 2010, 14:06:29)
> > [GCC 4.2.4] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> > (InteractiveConsole)
> > >>> import models
> > Traceback (most recent call last):
> >   File "<console>", line 1, in <module>
> >   File "/home/jhayward/invdb/models.py", line 50, in <module>
> >     class architecture(models.Model):
> >   File
> > "/tools/python/2.7/Linux_x86_64/lib/python2.7/site-packages/django/db/model 
> > s/base.py",
> > line 48, in __new__
> >     kwargs = {"app_label": model_module.__name__.split('.')[-2]}
> > IndexError: list index out of range
>
> > What is going on in this error message?
>
> The "English" translation is "list index out of range".
>
> As to what causes it, I'd guess that model_module.__name__ has not '.' in
> it, so the split returns a list of one item, and -2 is then an illegal
> index.
>
> This would seem to be because your models.py is in the same directory as
> your manage.py (and presumably settings.py), thus your ability to try and
> import it as just "import models".  Looking at the base.py code, it really
> expects a models.py file to be in a package (an app package, whose name this
> code is trying to figure out), and fails when it is not.
>
> The fix, if all this is true, is to create a sub folder for your "app", put
> the models.py (and views.py and maybe forms.py, admin.py, app specific
> urls.py) in that folder, allong with a (probably empty) file called
> __init__.py (that's two underscores before and two after, the word init).
> The name of this folder becomes your app name, e.g.; "my_app".  Then you
> would retry your experiment by typing "import my_app.models".
>
>
>
>
>
> > It occurred after I went through and added docstrings, __str__(), and
> > __unicode__() methods; I get the same error, referring to the same class,
> > when I go through and comment out the docstring and __str__() and
> > __unicode__() methods.
>
> > What are the likely causes, and what can I do to fix this?
>
> > --
> > [image: Christos Jonathan Hayward] <http://jonathanscorner.com/>
> > Christos Jonathan Hayward, an Orthodox Christian author.
>
> > Author Bio <http://jonathanscorner.com/author/> • 
> > Books<http://cjshayward.com/>
> >  • *Email <christos.jonathan.hayw...@gmail.com>* • 
> > Facebook<http://www.facebook.com/christos.jonathan.hayward>
> >  • LinkedIn <http://www.linkedin.com/in/jonathanhayward> • 
> > Twitter<http://twitter.com/JonathansCorner>
> >  • *Web <http://jonathanscorner.com/>* • What's 
> > New?<http://jonathanscorner.com/>
> > I invite you to visit my "theology, literature, and other creative works"
> > site.
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@google 
> > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.

Reply via email to