Re: Django 2.2 Media files

2019-07-06 Thread John Bagiliko
You need {{ item.image.url }} on your template since you are iterating through the context you passed in views. I'm sure you did something like this in views def home(request) images = Your_model.objects.all() context = {'images': images} return render(request, 'path_to/your/template',

Re: Django 2.2 Media files

2019-07-05 Thread Michał Ratajczak
Oh yeah! That's it ! Big thank's for you :) W dniu piątek, 5 lipca 2019 22:14:52 UTC+2 użytkownik Jani Tiainen napisał: > > Hi. > > What you did is correct and expected. > > Upload_to is relative path to MEDIA_ROOT in case of normal file upload > backend. There are many others like S3. > > Now

Re: Django 2.2 Media files

2019-07-05 Thread Jani Tiainen
Hi. What you did is correct and expected. Upload_to is relative path to MEDIA_ROOT in case of normal file upload backend. There are many others like S3. Now MEDIA_URL is absolute path of web server which points to MEDIA_ROOT. In development you can use static file serving trick like you did.

Re: Django 2.2 Media files

2019-07-05 Thread Michał Ratajczak
I Remove upload_to and it still wasn't working and next i did in my template.html: {% get_media_prefix as *STATIC_PREFIX* %} <- i added this line because {{ item.image }} returns only 'image.jpg'. Now a url is correct :) {% for item in images %} {% endfor %}

Re: Django 2.2 Media files

2019-07-05 Thread Anonymous Anon
I just find it really useful to save it in Google cloud On Fri., Jul. 5, 2019, 8:25 a.m. John Bagiliko, < john.bagil...@aims-senegal.org> wrote: > Since you already configured static folder called media in settings.py, if > you specifify upload_to='/media', Django will create a folder 'media' >

Re: Django 2.2 Media files

2019-07-05 Thread John Bagiliko
Since you already configured static folder called media in settings.py, if you specifify upload_to='/media', Django will create a folder 'media' inside the media folder. On Fri, Jul 5, 2019, 2:21 PM John Bagiliko wrote: > Remove the upload_to in the model. > > On Fri, Jul 5, 2019, 12:55 PM

Re: Django 2.2 Media files

2019-07-05 Thread John Bagiliko
Remove the upload_to in the model. On Fri, Jul 5, 2019, 12:55 PM Michał Ratajczak wrote: > Hi, i'm new in Django, I'm trying to configure media files correctly. > > That's in my model.py: > > class Question(models.Model): > description = models.CharField(max_length=200) > image =

Django 2.2 Media files

2019-07-05 Thread Michał Ratajczak
Hi, i'm new in Django, I'm trying to configure media files correctly. That's in my model.py: class Question(models.Model): description = models.CharField(max_length=200) image = models.ImageField(upload_to='media/', null=True, blank=True) in settings.py: STATIC_URL = '/static/'