Hi,

i have a class with an imagefield.
I'm trying to add the current logged in user to the path where the image
field is saved.
image = models.ImageField(upload_to="img/_USER_/icons/", blank=True )

_USER_ is a placeholder for the "real" user.

def add_icon(request):
    IconForm = forms.models.form_for_model(Icon)
    if request.method == 'POST':
        form = IconForm(request.POST)
        if form.is_valid():
            icon = form.save(commit=False)
            icon.image = icon.image.replace("_USER_",str(request.user))
            icon.save()
            return HttpResponseRedirect("/")
    else:
        form = IconForm()
    t = loader.get_template('main/add_icon.html')
    c = Context({
        'form': form,
    })
    return HttpResponse(t.render(c))

This doesn't work as it's still saved with _USER_ in the path.
Any ideas?

Thanks,
Benedict


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to