hi djangonaughts,

i have the following problem:

i have a Photo model, among other things it contains:


[=== models.py ===]

import os
def get_image_path(instance, filename):
    return os.path.join('photos', filename)

class Photo(models.Model):
        ...
        image = models.ImageField('image', upload_to=get_image_path)
        ...
        
[=== views.py ===]

def upload_photo(request):
    if request.method == 'POST':
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            gallery = form.cleaned_data['gallery']
                        .....
            image = form.cleaned_data['image']
            uploaded_photo = Photo(
                gallery = gallery,
                ...,
                image =image
            )
            uploaded_photo.save()
            return HttpResponseRedirect('/')
    else:
        form = UploadFileForm()
        

[=== forms.py ===]

class UploadPhotoForm(ModelForm):
    class Meta:
        model = Photo

        
When i try to upload using the admin interface, everything works as
expected.. when i try using my form
i don't get an error, but it doesn't work...

from what i can see with admin i get the expected location (expected
from the upload_to)

http://127.0.0.1:8000/site_media/photos/photo1.jpg

while with my form i get

http://127.0.0.1:8000/site_media/photo1.jpg

any ideas?

-nicolas

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