On Mon, 2009-01-26 at 20:39 -0800, chatchai wrote:
> Hi,
> 
> I want to unique upload file and there is not unique parameter
> available for file field model. I think I can do this at the form
> level but I just want to make sure if it is the best way to go.

The simplest way is to let Django do it for you by doing nothing special
at all (this is the default behaviour). When Django is trying to save a
file, it first checks that no file exists with that name. If one does,
it modifies the name slightly and repeats until a unique name is arrived
at.

Try it out for yourself: create a simple model that has a name and a
file upload field. Add two instances via the admin and uploading the sme
file. You'll notice that two copies are stored on disk, with two
different names.

Regards,
Malcolm



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