Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » English translation for error message? [RSS Feed]

#1 Dec. 21, 2010 22:53:27

Jonathan H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

English translation for error message?


$ python manage.py shell
Python 2.7 (r27:82500, Dec 2 2010, 14:06:29)
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/models/base.py",
line 48, in __new__
kwargs = {"app_label": model_module.__name__.split('.')}
IndexError: list index out of range
>>>

What is going on in this error message?

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?

--
<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.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Dec. 21, 2010 23:10:44

Bill F.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

English translation for error message?


On Tue, Dec 21, 2010 at 5:53 PM, Jonathan Hayward <
christos.jonathan.hayw...@gmail.com> wrote:

> $ python manage.py shell
> Python 2.7 (r27:82500, Dec 2 2010, 14:06:29)
> 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/models/base.py",
> line 48, in __new__
> kwargs = {"app_label": model_module.__name__.split('.')}
> 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?
>
> --
> <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...@googlegroups.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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Dec. 22, 2010 19:46:39

Nick S.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

English translation for error message?


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:
> > $ python manage.py shell
> > Python 2.7 (r27:82500, Dec  2 2010, 14:06:29)
> > 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('.')}
> > 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?
>
> > --
> > <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 athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » English translation for error message? [RSS Feed]

Board footer

Moderator control

Enjoy the 18th of August
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support