On Feb 24, 2:36 pm, Tonu Mikk <tm...@umn.edu> wrote:
> In my case I have the files already on the web server.  The only thing
> that I need to do is to link to them from the database.  When I try
> using the method above, I first read the file into memory like so
> (http://docs.djangoproject.com/en/dev/topics/files/#topics-files):
>
> >>> from django.core.files import File
>
> # Create a Python file object using open()
>
> >>> f = open('/tmp/hello.world', 'w')
> >>> myfile = File(f)
>
> Then I save it with the above method.  The problem I am running into, is that 
> when saving the file, it gives is a different name which is the original name 
> with an
> "_" at the end.  The link in the database also points to the file with this 
> new name.  How can I simply create a link in the database to the original 
> file?
>
> Thank you,
> Tonu

Use a FilePathField rather than a FileField. This just takes a path,
rather than a file object. See:
http://docs.djangoproject.com/en/dev/ref/models/fields/#filepathfield
--
DR.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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