ƒilin
Hello everybody. How i can connect input in template with model field. What i mean: <input class... name=.. value=..> Using {{ form.as_p }} or {{ form.field }} isn’t my way because I want to add some css classes to this inputs
Артем
hello everyone, how to display .docx in template or in brawser ?
Артем
i tried wtih iframe, but i couldnt
Unknown
https://youtu.be/6-XXvUENY_8
Unknown
He's using widget
Unknown
hello everyone, how to display .docx in template or in brawser ?
Really don't know about this dude sorry..
Артем
oh
Артем
thanks, but how know about it?
Артем
so i solved thiw problem
Артем
thanks all))))
¿
hi , i use DetailView and context_object_name = 'product' , I wanna know how can i show products image in template????
Champak Lal
Value error incorrect length aes 20
Champak Lal
Plz help
Bwaks
Hello At my html......{{ team.team_photos.url}}......it's not showing images on browser At my model.... photo=models.ImageField(upload_to='team_photos/%Y/%m/%d/') help
Bwaks
Might be problem while uploading photos
But the photos are in the team_photos and can be viewed in the admin section
Rakesh
,check the upload folder once
Bwaks
,check the upload folder once
The photos I uploaded are in the foldeey
Bwaks
*Folder
Bwaks
Yeah in a dynamic manner
Bwaks
<div class="testimonials-carousel swiper-container"> <div class="swiper-wrapper"> {% for team in teams %} <div class="testimonial-item swiper-slide"> <img src="{{ team.team_photos.url }}" class="testimonial-img" alt=""> <h3>{{team.first_name}} {{team.last_name}}</h3> <h4>{{team.designation}}</h4> <div class="social-links mt-3"> <a href="#" class="twitter"><i class="bx bxl-twitter"></i></a> <a href="#" class="facebook"><i class="bx bxl-facebook"></i></a> <a href="#" class="instagram"><i class="bx bxl-instagram"></i></a> <a href="#" class="linkedin"><i class="bx bxl-linkedin"></i></a> </div> <p> <i class="bx bxs-quote-alt-left quote-icon-left"></i> Proin iaculis purus consequat sem cure digni ssim donec porttitora entum suscipit rhoncus. Accusantium quam, ultricies eget id, aliquam eget nibh et. Maecen aliquam, risus at semper. <i class="bx bxs-quote-alt-right quote-icon-right"></i> </p> </div> {% endfor %} </div> <div class="swiper-pagination"></div> </div>
Bwaks
Still not working
Bwaks
Okay
Bwaks
team.photo.url
But it's stored in team_photos folder
Morteza
But it's stored in team_photos folder
you have to mention the field name
Morteza
not the folder
Bwaks
you have to mention the field name
photo=models.ImageField(upload_to='team_photos/%Y/%m/%d/')
Morteza
photo=models.ImageField(upload_to='team_photos/%Y/%m/%d/')
your field name is photo so like other fields, you call it by it's name not the folder name
Morteza
if you look into your database django saves the path of your image /team_photos/year/month/d/name_of_the_image.jpg
Morteza
if you look into your database django saves the path of your image /team_photos/year/month/d/name_of_the_image.jpg
by calling your field name with url method django generate the media fullpath for you
Morteza
Bwaks
so you're ok now
but its still not working
Morteza
but its still not working
did you upload an image?
Morteza
did you provide media_root in settings.py?
Morteza
and media_url
Bwaks
did you upload an image?
when i click this .... Currently: team_photos/2021/06/12/4190516.jpg..... as the admin it works
The
Hello Who can help me with resources to master Django I'm new to Django
Bwaks
and media_url
MEDIA_ROOT = os.path.join(BASE_DIR / 'media') MEDIA_URL = '/media/'
Javohir
it is there
Oo now I see it😅
Bwaks
show me your base project urls.py
from django.contrib import admin from django.urls import path,include from django.conf.urls.static import static from django.conf import settings from django.conf.urls import url urlpatterns = [ path('admin/', admin.site.urls), path('',include('pages.urls')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Morteza
before team.photo.url add /media/
Morteza
/media/{{ team.photo.url }}
Morteza
Still not
inspact your page see the url path and send it to me
Morteza
and open it in your browser see its showing on or not
ford
MEDIA_ROOT = os.path.join(BASE_DIR / 'media') MEDIA_URL = '/media/'
I think using path library is much easy so no need for os.path just do MEDIA_ROOT = str( BASE_DIR / 'media')
Bwaks
and open it in your browser see its showing on or not
console is giving this error message ......Failed to load resource: the server responded with a status of 404 (Not Found)
Bwaks
inspact your page see the url path and send it to me
<img src="/media//media/team_photos/2021/06/12/4190516.jpg" class="testimonial-img" alt="">
Morteza
and refresh the page
Morteza
then open the url in your browser if its not showing on your image is deleted!
Bwaks
remove the first media that i told you to append
<img src="(unknown)" class="testimonial-img" alt="">
Bwaks
{{ team.photo.url }}
<img src="/media/team_photos/2021/06/12/4190516.jpg" class="testimonial-img" alt="">
Morteza
upload another image and test it
Bwaks
it's true now
but not showing on browser
Morteza
Bwaks
Thank you guys i really appreciate your help
Morteza
you'r welcome!
The
Hello Who can help me with resources to master Django I'm new to Django