Human
But if it was one queryset object I can do the condition... But when its a list of query set... How to do that for each objects?
Human
Using Annotate?
Human
Likes = ManytoManyfield(User) this is what I have... In model...
I need to check in each post that the user id is in the many to many field.
Beka
Human
Omg... 😅 Why is this really difficult to convey...
Beka
You're jumping from one issue to another... concentrate and fix one issue))
Human
Bro,
In the get_context_data we will get the queryset....
Which will be the list of objects of Posts.
In the Posts Model I have Likes = models.ManytoManyField(User)
So there will be many users who liked the post...
I need to check the current user is liked(in many tomany field the user id should be there.)
So how to check it and send it to frontend...
Human
Then only I can show that the post is already liked or not in front end...
Human
Like and unlike is working fine. But I'm not able to show whether the post is liked or not.
Beka
{% for post in posts %}
<div>
<p>{{ post.tweet }}</p>
{% if post.liked_by_user %}
<p>Liked by you!</p>
{% else %}
<button onclick="likePost({{ post.id }})">Like</button>
{% endif %}
</div>
{% endfor %}
Beka
Sorry, by solution is still the same.
Use Ajax request for onclick and I've already sent the handling ajax request.
That's all from me.
Thank you
Beka
and good luck*
Human
Bro you used liked_by_user in the for loop but how it's actually work? There is no variable like that.
Human
Thank you Devs.... Thank you very much... It worked well...
The change I made was in the for loop
{% for post in object_list %}
{% if request.user in i.likes.all %}
# user is liked
{% endif %}
Beka
Beka
Human
Okay thanks
Simon
I am creating a registration application. I have a problem, if the user enters his email and password and submits, a new user will be created and he will be given an access and refresh token. And then a verification code will be sent to him. Here the user introduces himself with the access token. What happens if the refresh token expires here. He cannot proceed to the login page until he confirms the code.
The Inspired
Simon
Shriraj
Why is my django website not fetching CSS properties
Shriraj
It' show plain HTML structure and a image which isnt really alligned
Shriraj
Details as in dejango which details?
pranav
The Inspired
The Inspired
or just logout the user if both of it expires. he will have to log in again and get the tokena freshly
Simon
king
Hello please I wanted to ask
Can one create a fully customized admin panel with Django?or the default admin panel is a must in all Django apps
Papy
king
The Inspired
Tom
Guys. Can you please suggest the best resources to learn django (project based). Either ebooks or Udemy courses
Simon
I am creating a registration application. I have a problem, if the user enters his email and password and submits, a new user will be created and he will be given an access and refresh token. And then a verification code will be sent to him. Here the user introduces himself with the access token. What happens if the refresh token expires here. He cannot proceed to the login page until he confirms the code.
Beka
Fritz Flores
Does anybody have a tutorial on how to deploy a Django website on VPS hostinger ?
I’m having trouble setting it up.
MaX
Samir Arvind Saitwal
Did anyone has project which will provide how to develop web socket in django? If yes please share links
Maxim
#
Does any boy can help me with this ?
Our project currently following the restframework simple jwt . Libraray for authentication
Basically user send email and password we are returning a jwt acces token as response
With using that token access token he can able to access all the API s passing jwt as bearer token in headers
This approcah we are following on 2 projects
Now i need to creat one django app that should
act as like SSO (single sign on ) valid for both projects like sharing one jwt token per user to access both project apis. Can anybody help me atleast rough idea or suggested articles.
Mirco
Majid
Django 5 by example pdf
Any body can help me to do it?
Aditya
Can anyone help me in completing thus
Doragonsureiyā
Can anyone help me in completing thus
This group is to help you on specific issues you have on YOUR code, so you have to show the code you wrote and explain where and why you are stuck... as simple as that
_PRANAV_
Shriraj
Shriraj
Didn't do any changes to any css files
Mirco
Doragonsureiyā
This is not a Django specific question, please delete your offtopic message.
If it's a Python related question go to @Python group, otherwise please move to @PythonOfftopic group and ask there.
Aditya
How to properly develope chat application backend using django rest api
Doragonsureiyā
Maxim
Charly
AT
Hello
I’m new to Django, although I learnt python Basic already, do I need to learn Java and HTML too. Or there would be no need
Maxim
Rober
AT
tan (θ)
can anyone recommend me better frontend libraries for django beyond those
1. bootstrap / tailwind
2. htmx
3. alpine.js
Charly
Charly
Use whatever you want but here we don't discuss frontend development
Григорий
Why do many programmers dislike using django when creating websites? Is it slow?
Charly
Charly
pranav
pranav
Swetty
Why my djangoapp (home) cant read my static files, but getting access to media and django admin can read static files with media?
p.s.
python manage.py collectstatic has done
tree&logs&code here - https://paste.aiogram.dev/aduyogawik.csharp
The Inspired
Swetty