On Sep 17, 2008, at 11:45 PM, Mathieu Leplatre wrote:
>
> Hi all,
>
> I am starting a new thread, the first one became off-topic (http://
> groups.google.com/group/django-users/browse_thread/thread/
> 34b501d2d1f88496/f8a5d5ef5aeab62a)
>
> I want to do a simple external script that just relies on django's
> ORM.
> So I did a single file testdjango.py :
> ------
> import sys, datetime
>
> from django.conf import settings
> settings.configure( DATABASE_ENGINE = "sqlite3",
> DATABASE_NAME = "./testbase.db",
> INSTALLED_APPS = ('polls'))
There's a common gotcha related to Python tuples – tuple elements need
to be separated by commas, even if there's only one element.
INSTALLED_APPS = ('polls',) will do what you want. Right now, the
parentheses are being interpreted as grouping a single expression, and
when the code runs "for app in INSTALLED_APPS" it iterates over the
characters in the string 'polls', instead of the strings in the tuple.
Hope that helps,
Eric
>
>
> from django.db import models
> class Poll(models.Model):
> question = models.CharField(max_length=200)
> pub_date = models.DateTimeField('date published')
> class Meta:
> app_label = "polls"
>
> # Create sqlite database :
> from django.core.management import call_command
> call_command('syncdb')
> ------
>
> I have an error about app_label :
> Error: No module named p (first label of my app label)
>
> I tried verbosity=2 and DEBUG=True, but I don't get more information.
>
> If I put my script in a module and remove Meta :
> File "[...]/django/db/models/base.py", line 51, in __new__
> kwargs = {"app_label": model_module.__name__.split('.')[-2]}
> IndexError: list index out of range
>
> Thanks for your comments !
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---