PythonistL wrote:
> Thank you Kieran and Rob for your reply. The reason why I want to know
> id of the record is that I would like to name a picture by the id
> number( for example the picture will be   4330.jpg if the record id is
> 4330) And then the  picture is linked with the record data.I would like
> to have an image( picture) separately from the database so I think that
> it is a solution(to link image   id_number.jpg with the table record).
> Or is it a wrong idea?

I think that you probably want the standard FileField or ImageField
described here:

http://www.djangoproject.com/documentation/model_api/

These fields do not actually store the file/image in the database, just
the name of the file.    You need to set MEDIA_ROOT/MEDIA_URL as
described in the documentation so that Django knows where to save the
file to disk.  If for some reason you want to go back from filename to
model then you can do a query based on the filename, remembering that
the path you are querying for is relative to MEDIA_ROOT.

e.g. mymodels.get_object(myfilefield__exact="myimage.jpg")

Kieran

Reply via email to