On Mon, Dec 20, 2010 at 11:00 PM, Morgan Wahl <morgy.w...@gmail.com> wrote:

> On Mon, Dec 20, 2010 at 4:49 PM, Marc Aymerich <glicer...@gmail.com>
> wrote:
> >
> >
> > On Mon, Dec 20, 2010 at 8:29 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
> >>
> >
> > I think that something like this should do the work:
> > Document.UploadFile.filename="rat.doc"
> > Document.save()
> >
> > --
> > Marc
> Um, I'm not sure what it is you're trying to demonstrate here... in my
> example bits of code Document and UploadedFile are Model classes, not
> instances.
>
>
Hi Morgan, sorry, Yes you're rigth,


d=Document(doctype='whatever')
d.save()
u=UploadFile(document_ptr=d, filename='rat.doc')
u.save()


sorry for the confusion here :S

-- 
Marc

-- 
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.

Reply via email to