On Tue, Mar 31, 2009 at 10:55 AM, Matias Surdi <[email protected]>wrote:

>
> I have the following model:
>
> class Document(BaseModel):
>     name = models.CharField(max_length=150,blank=True)
>     type = models.ForeignKey(DocumentType)
>     description = models.TextField(blank=True)
>     file =
>
> models.FileField(upload_to="data/documentation/document/%Y/%m/%d",blank=True)
>
>
> And suppose, I have the file "/tmp/test.txt" in my local filesystem.
>
> How could I add this file to a new model usign the django shell?
>
>
> I've tryed by instantiating a new Document, and then doing:
>
> object.file = File(open("/tmp/test.xt"))
> object.save()
>
>
> But this gives me the following error:
>
>
> Traceback (most recent call last):
>   File "./migrate.py", line 175, in <module>
>     object.save()
> [snip]
> "/usr/lib/python2.5/site-packages/django/db/models/fields/files.py",
> line 139, in __get__
>     (file.__class__, self.field.attr_class), {})
> TypeError: Cannot create a consistent method resolution
> order (MRO) for bases File, FieldFile
>
>
This is ticket #10249: http://code.djangoproject.com/ticket/10249

You could try the patch I attached there, though honestly I'm not
comfortable enough with what the code is doing there to say if that's a good
fix.  It does fix the MRO issue, I just don't know if it has other bad
implications.

Karen

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to