Hi,

Using django 1.3.1 with SQLlight backend. 
I want to use the following kind of model.


*class Bar(models.Model):
  a = models.PositiveSmallIntegerField(default=1)

class Foo(models.Model):
   mybar = 
models.ForeignKey(Bar,blank=False,null=True,on_delete=models.CASCADE)
   class Meta:
      abstract = True

class Sub(Foo):
  b = models.PositiveSmallIntegerField(default=1)

class SubFoo(Foo):
  c = models.PositiveSmallIntegerField(default=1)*


The model seems fine and validate correctly . corresponding created SQL is 



*CREATE TABLE "devLab_bar" (*
*    "id" integer NOT NULL PRIMARY KEY,*
*    "a" smallint unsigned NOT NULL*
*)*
*;*
*CREATE TABLE "devLab_sub" (*
*    "id" integer NOT NULL PRIMARY KEY,*
*    "mybar_id" integer REFERENCES "devLab_bar" ("id"),*
*    "b" smallint unsigned NOT NULL*
*)*
*;*
*CREATE TABLE "devLab_subfoo" (*
*    "id" integer NOT NULL PRIMARY KEY,*
*    "mybar_id" integer REFERENCES "devLab_bar" ("id"),*
*    "c" smallint unsigned NOT NULL*
*)*



When I try to create an 'SubFoo' item , I got an error about missing field.

*python manage.py shell*
*Python 2.7.3 (default, Sep 26 2012, 21:51:14) *
*[GCC 4.7.2] on linux2*
*Type "help", "copyright", "credits" or "license" for more information.*
*(InteractiveConsole)*
*>>> from devLab.models import Sub,SubFoo*
*>>> Sub().save()*
*>>> SubFoo().save()*
*Traceback (most recent call last):*
*  File "<console>", line 1, in <module>*
*  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", 
line 460, in save*
*    self.save_base(using=using, force_insert=force_insert, 
force_update=force_update)*
*  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", 
line 553, in save_base*
*    result = manager._insert(values, return_id=update_pk, using=using)*
*  File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 
195, in _insert*
*    return insert_query(self.model, values, **kwargs)*
*  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", 
line 1436, in insert_query*
*    return query.get_compiler(using=using).execute_sql(return_id)*
*  File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", 
line 791, in execute_sql*
*    cursor = super(SQLInsertCompiler, self).execute_sql(None)*
*  File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", 
line 735, in execute_sql*
*    cursor.execute(sql, params)*
*  File 
"/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 
34, in execute*
*    return self.cursor.execute(sql, params)*
*  File 
"/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py", 
line 234, in execute*
*    return Database.Cursor.execute(self, query, params)*
*DatabaseError: table devLab_subfoo has no column named mybar_id*
*>>>* 


I cannot figure out why I get this error.
thank in advance for any help.







-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/7VJOij2CFh0J.
To post to this group, send email to django-users@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