dancaron / Django-ORM

Django-ORM-Standalone Template - Use the power of Django's database functionality in regular python scripts.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I try to save model from Django IDLE shell and it gives me an error

pebreo opened this issue · comments

commented

Hello. I have Python 2.7 and Django 1.4.1 installed on Windows 7 machine. I have not modified the python files in any way.
I tried to run main.py and also in the Django IDLE shell but I get an error. This is what I do.

c:\foo> python manage.py shell

from db.models import User
user = User(name="Dan", email="dancaron@gmail.com")

but then I try to save:

user.save()
and I get the following error:

File "main.py", line 12, in
user.save()
File "C:\Python27\lib\site-packages\django\db\models\base.py", line 463, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "C:\Python27\lib\site-packages\django\db\models\base.py", line 551, in save_base
result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
File "C:\Python27\lib\site-packages\django\db\models\manager.py", line 203, in _insert
return insert_query(self.model, objs, fields, **kwargs)
File "C:\Python27\lib\site-packages\django\db\models\query.py", line 1576, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "C:\Python27\lib\site-packages\django\db\models\sql\compiler.py", line 910, in execute_sql
cursor.execute(sql, params)
File "C:\Python27\lib\site-packages\django\db\backends\sqlite3\base.py", line 337, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.DatabaseError: no such table: db_user

Why is this happening? Also, keep up the great work. I really like this Django-ORM!

commented

I got it to work by typing:

c:\foo> python manage.py syncdb

Hurray!

we do work for support python3 + django1.10 , you can use it