I have a model class, 'A_base', and a 2nd model class, 'A_derived'. When I 
save an object of A_derived, I want the data from both my base and derived 
class to be saved.

Example code looks like this:

    class A_base(models.model):
        name = models.CharField(max_length=50)

    class A_derived(A_base):
        role = models.CharField(max_length=50)


So when I call save(), I want to save an instance of the derived object, 
including the data in the base class into my sqlite3 database. I would like 
my code to look like this:

    ... 
    derived_obj = A_derived.objects.get(name="john")
    derived_obj.role = "parent"
    derived_obj.save()
    ... 

My question is whether the save method will save 'role' to the A_derived 
table and save 'name' to the A_base table? Or do I have to override the 
save method so that it saves 'role' and then calls the base class save 
method to save 'name'?

I tried doing this using the default save method and it created a stack 
trace, so I'm guessing that I am expecting too much from the default save 
method.

Jim A.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0c88e661-68d6-43a0-8a51-8f2c2d6aafa7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to