>
> Thanks, that's fine, but I was wondering if there was a more scalable
> way. I have more fields than just "description", so it would be nice
> if they could be all saved with one method call, so I don't have to
> maintain this code in case I change the model.
>
>
If you have multiple fields describing your image, and you are concerned
that more fields will be added/removed at a later time and don't want to
fiddle with your Image model fields, then it would probably be prudent to
factor out these fields to their own model, and hold a relationship (1-to-1,
probably) from the image model to the description model.


> > By the way, your overridden save() method looks a bit odd.  It needs to
> call
> > save() on its superclass as well.
>
> But I do:
> models.Model.save(self)
>
> Isn't that what you meant?
>

You're correct in that you call the superclass, I looked over it too
quickly.  However, the way you are doing it won't pass any of the args or
kwargs up to the superclass, and will probably give you problems.  Look here
http://docs.djangoproject.com/en/dev/topics/db/models/#overriding-model-methodsto
get an example.


> And how do I get that information provided by the user?
> Something like:
> Image i = ImageUploadDetailsForm.save(commit=False)
> ?
>

You get the info from the user by accessing the values in request.POST,
which is a dictionary-like object with all the POST parameters.  If you are
using a ModelForm, you might be able to get some things "automagically", but
you can always access them in request.POST no matter how the form is set
up.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
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