Re: Question IMAGE in Django
Also check the permissions on your images. I had set the FILE_UPLOAD_PERMISSIONS to 0640 in development, but this wasn't correct for my production server. Ensure that Apache or whatever user the webserver is running has read access to your images. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Question IMAGE in Django
Guys, can throw off to me to you on an e-mail my project to find an error - why the map is not output? I tried to do everything that to me prompted in it topic, but anything it is impossible to me --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Question IMAGE in Django
On Monday 22 June 2009 10:27:22 am Vlad(L) wrote: > Mike, excuse that I occupy your time. > > All has made also, but is not present Image. > I will write more in detail. When I instal, for example, "{{MEDIA_URL}} {{art.image}}" width=200;/> image it is not displayed > on html page, but the place under a figure and together with a red > dagger in a corner is displayed. If here it is possible to load a page- > screenshot - I would send. First verify that the generated url is correct, that django is producing the right url with the context. Then it would now be a problem of the image not being were you expect it or a misconfiguration of your urls.py. I would suspect the latter first, so you need to check that. For this, depending on your setup, you'll want to look at setting up django serve static files[1]. If you're using apache, you should follow the mod_python instructions [2]. For a seperate media server (url points to another domain such as media.yourdomain.com), then you should have your MEDIA_ROOT pointed to that domains document root. If this doesn't help and you are serving your media correctly, then you'll want to check your paths and make sure the actual file exists on the file system, where it should be. If all this is correct and you can view the image by itself in your browser, then follow the path of the earlier suggestions. Mike [1] http://docs.djangoproject.com/en/dev/howto/static-files/#howto-static-files [2] http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#id1 -- Is it NOUVELLE CUISINE when 3 olives are struggling with a scallop in a plate of SAUCE MORNAY? signature.asc Description: This is a digitally signed message part.
Re: Question IMAGE in Django
Mike, excuse that I occupy your time. All has made also, but is not present Image. I will write more in detail. When I instal, for example, image it is not displayed on html page, but the place under a figure and together with a red dagger in a corner is displayed. If here it is possible to load a page- screenshot - I would send. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Question IMAGE in Django
On Monday 22 June 2009 09:14:41 am Vlad(L) wrote: > art.html > > {% for art in art %} > {{ art.title }} > {{art.anonce }} > > > {% endfor %} > > This will add the media url that you set for MEDIA_URL in settings.py (as long as the context processor for media is also set) an example of mine: TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", } As long as the url generated points to the image, this should work. Mike -- Ever get the feeling that the world's on tape and one of the reels is missing? -- Rich Little signature.asc Description: This is a digitally signed message part.
Re: Question IMAGE in Django
Ok! views.py from booksite.books.models import Article from django.template import RequestContext def art(request): art = Article.objects.all() return render_to_response('art.html', {'art': art}, context_instance=RequestContext(request)) art.html {% for art in art %} {{ art.title }} {{art.anonce }} {% endfor %} I have made by your example, but all the same image is not displayed --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Question IMAGE in Django
On Monday 22 June 2009 08:06:25 am Vlad(L) wrote: > Mike, I work on Django 1.0.2 - in this version in settings.py is not > mentioned at all about Media context processor and RequestContext. To > me they need to be added in addition most??? It's not mentioned in the settings.py file, but that's why django has great documentation available for it. See the link I posted before on how to use the context processors. If you scroll up a little bit, the same page will show you how to use the RequestContext class to your benefit. In my case I use the render_to_response shortcut in my views and pass the context_instance variable set as such: context_instance=RequestContext(request) Full use is sample from views.py from sample.models import News from django.template import RequestContext def index(request): qs = News.objects.all()[:5] return render_to_response('index.html', {'items': qs}, context_instance=RequestContext(request) ) Doing so, django will apply the context processors to your request object, adding the contexts for use in your views. I'm going to make a small suggestion, while the books are a great resource, they should be used in addition to the actual documentation available, not instead of. Mike. -- A sense of humor keen enough to show a man his own absurdities will keep him from the commission of all sins, or nearly all, save those that are worth committing. -- Samuel Butler signature.asc Description: This is a digitally signed message part.
Re: Question IMAGE in Django
Mike, I work on Django 1.0.2 - in this version in settings.py is not mentioned at all about Media context processor and RequestContext. To me they need to be added in addition most??? --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Question IMAGE in Django
On Monday 22 June 2009 03:04:03 am Vlad(L) wrote: > Unfortunately, it is impossible. Through a browser has looked html > code - p> > > And how should be correctly registered MEDIA_URL in my case if I work > on built in server Django? In your settings.py check the context processors and make sure the Media context processor[1] is set and you pass the request object to your RequestContext[2] Mike [1] http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-media [2] http://docs.djangoproject.com/en/dev/ref/templates/api/#id1 -- We secure our friends not by accepting favors but by doing them. -- Thucydides signature.asc Description: This is a digitally signed message part.
Re: Question IMAGE in Django
def art(request): art = Article.object.all() retrun % (art) art.allow_tags = True try this .Add this in your model or if in admin then pass object .then use list_display to display the image.see docs for more help: http://docs.djangoproject.com/en/dev/ref/contrib/admin/ On Mon, Jun 22, 2009 at 4:11 PM, Vlad(L)wrote: > > It so needs to be made? > > > def art(request): >art = Article.objects.all() >return render_to_response('art.html', {'art': art}) > > art.allow_tags = True > > I so have written, but all the same it is impossible > http://127.0.0.1:8000/article/media/1.jpg > > It can is necessary to make, that the path was > http://127.0.0.1:8000/media/1.jpg > ? > > > > > --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Question IMAGE in Django
It so needs to be made? def art(request): art = Article.objects.all() return render_to_response('art.html', {'art': art}) art.allow_tags = True I so have written, but all the same it is impossible http://127.0.0.1:8000/article/media/1.jpg It can is necessary to make, that the path was http://127.0.0.1:8000/media/1.jpg ? --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Question IMAGE in Django
not got ur question.If u want to display image then set allow_tags=True. On Mon, Jun 22, 2009 at 3:34 PM, Vlad(L)wrote: > > Unfortunately, it is impossible. Through a browser has looked html > code - p> > > And how should be correctly registered MEDIA_URL in my case if I work > on built in server Django? > > > --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Question IMAGE in Django
Unfortunately, it is impossible. Through a browser has looked html code - And how should be correctly registered MEDIA_URL in my case if I work on built in server Django? --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Question IMAGE in Django
On 21/06/2009, at 11:14 PM, Vlad(L) wrote: > > MEDIA_ROOT = 'C:/booksite/media/' > MEDIA_URL = 'http://127.0.0.1:8000/media' > > ... > > I think this line should be more along the lines of: When you render the html, view the source, and make sure its rendering the right path. Access the image directly through the browser to make sure you have the path correct. Hope that helps, Pawel. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Question IMAGE in Django
Nick, thanks! But I unfortunately cannot still make. My problem: that in the Template the picture was displayed For example, I load in Django Admin article, I write title, anonce, body and I load Image... It is necessary For me, that Image it was deduced on a site together with title, anonce, body My new code: settings.py MEDIA_ROOT = 'C:/booksite/media/' MEDIA_URL = 'http://127.0.0.1:8000/media' models.py class Article(models.Model): title = models.CharField(max_length=200) anonce = models.TextField() body = models.TextField() url = models.URLField(unique=True) date = models.DateTimeField() image = models.ImageField(upload_to='media/') views.py def art(request): art = Article.objects.all() return render_to_response('art.html', {'art': art}) art.html {% for art in art %} {{ art.title }} {{art.anonce }} urls.py urlpatterns = patterns('', ('^$', index), (r'^books/$', archive), (r'^pub/$', publisher), (r'^article/$', art), (r'^admin/(.*)', admin.site.root), ) For some reason for me title, anonce are output well, and image it is not output - there an empty square with a red dagger in a browser... --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Question IMAGE in Django
> I study Django 1.0.2 on Djangobook > Has read not all, but why that I can not find in this book the > information anywhere how to be with Image? In the book the example > with three models - Authors, Publisher and Books is resulted. And if I > want still the Image to books and that they were output in templates > in the identical sizes??? > Prompt, please where to find such information Your question isn't very clear but I'll try and help with what it sounds like you're asking: How to get images into your template? If so how about something like this: In booksite/books/templates/pub.html {% extends "base.html" %} {% block title %}Книги{% endblock %} {% block banner %}{% endblock %} {% block content %} {% for x in pub %} {{ x.name }} {{ x.address }} {{ x.website }} {% endfor %} {% endblock %} Or you could use: /images/pub/{{ x.id }}-thumbnail.jpg Hope that helps? Nick --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---