imagefield

How to render images on Django template

a 夏天 提交于 2019-12-01 13:43:32
See my GitHub https://github.com/rg3915/gallery How to render images on Django template? But he is returning: Gallery media/3665_1280x800_8UX8tgG.jpg Tour de France media/281405_fSRBDZu.jpg bike of children How to render the images? Does the bug is in settings.py Regis da Silva urls.py from django.conf import settings from django.conf.urls import patterns, include, url from django.conf.urls.static import static from gallery.core.views import * from django.contrib import admin urlpatterns = patterns( 'gallery.core.views', url(r'^$', 'home', name='home'), url(r'^gallery/$', GalleryList.as_view()

How to render images on Django template

Deadly 提交于 2019-12-01 11:03:03
问题 See my GitHub https://github.com/rg3915/gallery How to render images on Django template? But he is returning: Gallery media/3665_1280x800_8UX8tgG.jpg Tour de France media/281405_fSRBDZu.jpg bike of children How to render the images? Does the bug is in settings.py 回答1: urls.py from django.conf import settings from django.conf.urls import patterns, include, url from django.conf.urls.static import static from gallery.core.views import * from django.contrib import admin urlpatterns = patterns(

upload image to imagefield with djangorestframework using json and test this with CURL

与世无争的帅哥 提交于 2019-11-30 14:06:24
问题 I have made several apis in djangorestframework. This I could test both with the html form of the api as with curl in commandline. Now I have an api to a Model with one off the fields an ImageField. I can't figure out which curl command to use. Using the syntax I used before fot post actions in json format, it would be: curl -X POST -S -H 'Content-Type: application/json' -u "username:password" --data-binary '{"otherfields":"something", "photo":"/home/michel/test.jpg"}' 127.0.0.1:8000/api/v1/

Can't find an input type=image value in $_POST

瘦欲@ 提交于 2019-11-29 12:23:05
Well may be it is to easy question but: I want to sort the numbers by clicking an image. I thought that i make a form and add an imagefield. <form id="form1" name="form1" method="post" action="index.php"> <input name="buyuka" type="image" src="resimler/azalt.gif" /> </form> Then i will write these codes. $sorgu='SELECT * FROM urunler'; if(isset($_POST['buyuka']) { $sorgu='SELECT * FROM urunler ORDER BY uyeno DESC'; } $sonuclar=mysql_query($sorgu); However it doesn't sort. When i try adding submit button in order to add imagefield, it works. So it means i make a really basic mistake but i cant

Replacing a Django image doesn't delete original

痞子三分冷 提交于 2019-11-28 18:18:48
In Django, if you have a ImageFile in a model, deleting will remove the associated file from disk as well as removing the record from the database. Shouldn't replacing an image also remove the unneeded file from disk? Instead, I see that it keeps the original and adds the replacement. Now deleting the object won't delete the original file only the replacement. Are there any good strategies to doing this? I don't want to have a bunch of orphan files if my users replace their images frequently. The best strategy I've found is to make a custom save method in the model: class Photo(models.Model):

Submit form (django-form) with Imagefield via Jquery/Ajax Post?

不问归期 提交于 2019-11-28 13:34:48
问题 Im having some problems submitting a form (Django-form) with a imagefield with Jquery/ajax POST. Im getting back "Field required" validation errors on the imagefield.. I been trying different solutions with appending formData but with no results so far. Am i on the right track? Please point me in the right direction. Thank you! Update: I can set the imagefield to required=false and not get the validation error but i want the field to be required and it seems like the form still doesn't submit

Image file not deleted when object with ImageField field is deleted

。_饼干妹妹 提交于 2019-11-28 09:58:58
I've got a model Picture with an ImageField . When deleting an instance of Picture , the file set in the ImageField is not deleted. Is it a bug? How can I do it? Chris Pratt Deletion of files associated with FileField s and ImageField s was intentionally removed in Django 1.3. See ticket #6456 . Django uses transactions extensively to prevent data corruption if something goes wrong with the request. If a deletion transaction is rolled-backed, after the file has been deleted from the filesystem, then you now have a record pointing to a non-existent file. All tickets asking for automatic

Django - How can I display a photo saved in ImageField?

≯℡__Kan透↙ 提交于 2019-11-28 07:45:40
I've been going around in circles for hours with this. I have a UserProfile model with profile_pic ImageField. I saved the user photo and now I want to display it, but nothing works. I went through docs, SO, google, with no result. I uploaded a photo, and I can see that the url was saved in the database. This is what I have: # models.py class UserProfile(models.Model): ... title = models.CharField() about_me = models.CharField() profile_pic = models.ImageField(upload_to=content_file_name, blank=True) # views.py def user_details(request): if request.method == 'POST': form = UserProfileForm

Override django's model delete method for bulk deletion

心不动则不痛 提交于 2019-11-28 06:56:09
I'm overriding Django's model delete method in order to delete orphan files in the disk for image fields, something like this: class Image(models.Model): img = models.ImageField(upload_to=get_image_path) ... def delete(self, *args, **kwargs): self.img.delete() super(Image, self).delete(*args, **kwargs) This works fine when I delete single objects from the admin, but when I select multiple objects and delete them, this doesn't seem to get called. I have been googling for a while but haven't hit the right keywords to get the answer for this, nor the official documentation seems to talk about

Can't find an input type=image value in $_POST

。_饼干妹妹 提交于 2019-11-28 05:55:53
问题 Well may be it is to easy question but: I want to sort the numbers by clicking an image. I thought that i make a form and add an imagefield. <form id="form1" name="form1" method="post" action="index.php"> <input name="buyuka" type="image" src="resimler/azalt.gif" /> </form> Then i will write these codes. $sorgu='SELECT * FROM urunler'; if(isset($_POST['buyuka']) { $sorgu='SELECT * FROM urunler ORDER BY uyeno DESC'; } $sonuclar=mysql_query($sorgu); However it doesn't sort. When i try adding