On Feb 17, 2009, at 5:17 AM, Carmelly wrote:

>
> My situation is this: I want to allow my users to upload multiple
> userpics and then choose between them. So I have a Profile model with
> an ImageField for the userpic. When users upload a file it is
> displayed around the site as usual. When they upload a new file, that
> file replaces their the "userpic" field in their Profile and is
> displayed all over the site, but the old userpic is not overwritten on
> disk. This is what we want.

Have you tried this out? So far as I can see, ImageField and FileField  
uploads don't overwrite old files, even if the filename is the same  
(underscores are appended to the filename). This much should be  
working already.

> Now, if I display a page for the user with all the userpics they ever
> uploaded and let them choose between them, how can I set the path in
> the ImageField to the file the chose? I know there is a userpic.save()
> method, but I'm not sure what to pass into it, or if this is even the
> correct way to go about it.

You could do something hacky where a view displays the contents of a  
directory and allows you to manipulate what you find there, but  
probably what you want is a separate UserPic model, with a M2M  
relation to your Profile. That way each user can have as many pics as  
they want, they can be accessible inline from their profile page, and  
you'll have the convenience of working with a proper django model  
instance. Put a datetime attribute on each photo, and you can use that  
to sort and display the most recently uploaded.

Hope that helps,
Eric

> >


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