Add Default Profile Pic With Static Files - Django Blog #29

preview_player
Показать описание
In this video we'll add a default profile picture using Django Static Files to our Blog.

In the last video we set up profile pictures and output a user bio under each blog post. But what happens if the user doesn't upload a profile picture? We need to output a generic default profile pic and we'll do that by setting up Static Files.
Рекомендации по теме
Комментарии
Автор

▶️ Watch Entire Django Blog Playlist ✅ Subscribe To My YouTube Channel:
▶️ See More At: ✅ Join My Facebook Group:

Codemycom
Автор

Awesome Playlist on django blog and very awesome teacher. Waiting for the next videos of the django blog

gkulk
Автор

Hello John,

I have a question about 02:22.

{% if %}
<img src= "{{ }}"
class="card-img">
{% endif %}

for this part, when I have profile-photo user there is no problem.
when I have nonprofile-photo user there is "ValueError: The 'profile_pic' attribute has no file associated with it." error. But you had blank profile photo place and blog was opening.

Be sure I tried to fix by myself at least 1 hour but I couldnt find.

Thanks.

leosoltys
Автор

got a question: how can you concatenate de src value on the img tag that shows up in {% else %} block, with a jinja value like {{request.user.id}} per say?

theBlisster
Автор

Thank you for your video, it's great video, would you please explain why need another statement of STATICFIELS_DIRS = [
os.path.join(BASE_DIR, 'static')], if we already had STATICFIELS_DIRS = (os.path.join(BASE_DIR, 'static')) in our setting page. Thank you for your answer.

joelee
Автор

I followed this video 4 times to see if I did anything wrong but my static files wont load. The video after this doesnt help either. That If statement to load the static file when someone has no profile pic, it keeps sending back a 404 in the terminal and I truly have no idea why. It shows the path in the tools and in the terminal but to no avail. I worked around it by moving my default pic to the media/images folder and linking the img src to

WhisperinScream
Автор

Thanks for the informative video, nice teacher 👍👍👍

mtrkhan
Автор

How to display a randomly chosen profile picture, from a folder with default pictures, once a user signs up?

Naught
Автор

Thank you for posting it, before it's timeline 😊

vineelvarmapenumatsa
Автор

I don't know why but it is still giving "The 'profile_pic' attribute has no file associated with it." error and yes I have the old version of django which has os module imported already.

ashutoshrai
Автор

❤️Thank you for saving my project, this video is the most useful tutorial I found

verama
Автор

Meet same issue with me. "invalid block tag on line 4: 'static', expected 'endblock'. Did you forget to register or load this" add {% load static %} after {% extends 'base.html' %}

wowoz
Автор

Hey, sorry for the late comment, I just found out about the series and I am almost done with the project. I have one question that I can't really get my head around and if you could answer it I would appreciate it heavenly. I want to make the home page, (where the posts are shown) with cards from bootstrap and to use the grid from bootstrap. I would like to get 4 posts in a row and then continue with the others below them. I tried by splitting the object_list in lists containing chunks of 4 elements. I tried Paginator but without result. Can you help me please, I am in need of help. Thank you!

rroctav
Автор

Thank you!!!! Thought I was going crazy before found this video

horger
Автор

this vid helped me detangle my mind. I was having issues using "default" property of imagefile field vs just KIS and do what is in the video.

efrainvalles
Автор

as usual you surprise us thanks i'm looking for more

sulimanallahgabo
Автор

Bob Base_dir defention changed in newer versions hence running into problems any updates to fix it

sajeersayed
Автор

help pls. GET HTTP/1.1" 404 1728.
my django version is 3.1.2, and i already did import os. but the image won't show up

carablejohnchristian
Автор

Yes sir this works, but what about the profile page? it will catch an error?

ali_sadrian
Автор

Thank you for your video, it's great tutorial. but i have a problem when the user have a profile without profile_pic ->The 'profile_pic' attribute has no file associated with it.

shadow-lmdh