Sent from my mobile device On Dec 20, 2010 8:04 PM, "morgan wahl" <morgy.w...@gmail.com> wrote: > Hello all, > > I was wonder if there is a way to turn a model instance into an > instance of a subclass of it's class. E.g.: > > class Document(models.Model): > doctype = models.CharField(max_length=256, blank=True, null=True) > > class UploadedFile(Document): > filename = models.CharField(max_length=256) > > Given a Document that isn't already an UploadedFile, can I turn it > into one? I know at the database level it's just a matter of inserting > a new row into the uploadedfile table with document_ptr_id = the > Document's id. I've tried > > doc = Document.objects.create(doctype='photo') > uf = UploadedFile( > document_ptr=doc, > filename='test.jpg', > ) > uf.save() > > But that seems to produce two separate instances (i.e. uf.doctype != > doc.doctype). > > Is there a way to do this? > > Thanks in advance. > -Morgan Wahl > > -- > You received this message because you are subscribed to the Google Groups "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com> . > For more options, visit this group at http://groups.google.com/group/django-users?hl=en. >
-- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.