Mathieu Leplatre wrote:
> Hi all,
>
> I found many post about specific errors regarding django as a
> standalone tool.
>
> With a little bit of researching, I ended up with this script below.
> Unfortunately, it fails on database initialization.
>
> ...
> ...
> File "/home/mathieu/Code/uhm/svn/uhm/django/db/backends/sqlite3/
> base.py", line 167, in execute
> return Database.Cursor.execute(self, query, params)
> sqlite3.OperationalError: no such table: polls_poll
>
> The sqlite file is empty (0 byte). How can I syncdb programatically
> (and only once) ?
>
> Thanks !
>
>
> import datetime
> from django.conf import settings
> settings.configure( DATABASE_ENGINE = "sqlite3",
> DATABASE_NAME = "./polls.db",
> INSTALLED_APPS = ('polls'))
> 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"
>
> p = Poll(question="What's up?", pub_date=datetime.datetime.now())
> p.save()
>
This is k=nd of a wild-assed guess. Please tell me if it works.
from django.core.management import call_command
call_command('syncdb')
regards
Steve
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---