On Thu, May 22, 2008 at 3:22 PM, poschs <[EMAIL PROTECTED]> wrote: > 1. I cant edit the ImageField by hand - e.g. If it currently contains > 'images\fam1.jpg' I cannot manually type in images\fam2.jpg and have > it accept it.
I don't follow what you're trying to do here. Does this "fam2.jpg" exist on your computer? ImageField works by uploading a file from your computer, not by just editing the filename in the database, so whatever you type in there would have to be a real file on your computer in order to work properly. > 2. If I select (using the browse button) the fam2.jpg image and it > (fam2.jpg) already exists in the images folder, it will upload it > again with a '_' appended to the filename (fam2_.jpg). This is normal behavior, and is well-documented. > 3. The documentation suggests that ImageFile uploads will go to > MEDIA_ROOT + ImageField(upload_to='images') which should be .../static/ > images/imagefile.jpg and this works fine. > > However, without putting '/static/' in the MEDIA_URL, the > get_ImageField_url method will return only .../images/imagefile.jpg. I > just stumbled on this, and its why I had to put '/static/' in the > MEDIA_URL setting. > > Without '/static/' in the MEDIA_URL setting, the upload works fine, > but the get_ImageField_url returns 'images/imagefile.jpg' rather than > MEDIA_URL + images/imagefile.jpg which causes the URL to be relative > to the current page (e.g. /page/2/images/imagefile.jpg rather than an > absolute path that doesnt include the /page/2/ relative information) get_FIELD_url() doesn't care about MEDIA_ROOT at all, it only cares about MEDIA_URL. Likewise, saving files only uses MEDIA_ROOT, and doesn't care at all about MEDIA_URL. They're two different settings because they have two different purposes. MEDIA_ROOT describes where the file should actually be stored, while MEDIA_URL defines what base URL those files will be available from. You do need both. > 1. How can I choose an existing image vs. having to always upload one? This would be something more like how FilePathField works, but I assume you'd still want the ability to upload new files, so you're really asking for a hybrid between FileField and FilePathField. I really can't imagine how we'd be able to get that to work reasonably well, especially in a way that makes sense when trying to use it. I'm open to ideas, but I doubt that's feasible. > 2. If I can only upload images, can I make it just overwrite an existing > image vs. appending the _? Right now, there's no easy way to do this. I've been working on a patch that will allow this, but it won't reach trunk for a while. > 3. Why does get_ImageFile_url not prepend the whole MEDIA_ROOT information? As mentioned, the url method only cares about MEDIA_URL, not MEDIA_ROOT. > Sorry for the verbosity. I did search the group for help on this first, > though :) The documentation is also an excellent place to look for things like this. -Gul --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---