Anonymous
AB
Hello guys What is the best course on YouTube
Arash
I want a function to run every Thursday or any day of the week, how can i achieve that?
Mirco
салли
Shan
Anyone know how to fetch username that executing from post request?
Carlos A.
Anyone know how to fetch username that executing from post request?
If you're using Django Rest Framework for building APIs, you access the username with this approach from rest_framework.views import APIView from rest_framework.response import Response from rest_framework.permissions import IsAuthenticated class MyAPIView(APIView): permission_classes = [IsAuthenticated] def get(self, request): username = request.user.username return Response({"message": f"Hello, {username}!"})
-
{% extends 'base.html' %} {% block content %} <div class="container"> <div class="row"> <div class="col-md-6"> <img src="{{movie.poster.url}}" width="300" height="300"> </div> <div class="col-md-6"> <small>By: {{ user.username }}<br> {{user.id}} </small> <h6>Title:{{ movie.title }}</h6> <h6>Description:{{movie.description}}</h6> <h6>Trailer Link:{{movie.trailer_link}}</h6> <p>User: {{ user.username }}</p> <p>Movie User: {{ movie.user.username }}</p> {% if movie.user == request.user or request.user.is_superuser %} <a class="btn btn-warning" href="{% url 'update' movie.id %}">update</a> <a class="btn btn-danger" href="{% url 'delete' movie.id %}">Delete</a> {% endif %} </div> </div> </div> {% endblock %}
Charly
Buttons not working
be way more specific
-
be way more specific
Show the buttons only for who added the post
Charly
Show the buttons only for who added the post
because you wrote that condition
-
def update(request,id): movie=Movie.objects.get(id=id) request_user=request.user form=Movieform(request.POST or None, request.FILES,instance=movie) if form.is_valid(): form.save() return redirect('home') return render(request, 'update.html',{'form':form,'movie':movie,"request_user": request_user})
Charly
in your template you need to use the first one
Charly
Wht
???
-
Any other solutions
Charly
Not working
show what you have done
-
show what you have done
{% extends 'base.html' %} {% block content %} <div class="container"> <div class="row"> <div class="col-md-6"> <img src="{{movie.poster.url}}" width="300" height="300"> </div> <div class="col-md-6"> <small>By: {{ user.username }}<br> {{user.id}} </small> <h6>Title:{{ movie.title }}</h6> <h6>Description:{{movie.description}}</h6> <h6>Trailer Link:{{movie.trailer_link}}</h6> <p>User: {{ user.username }}</p> <p>Movie User: {{ movie.user.username }}</p> {% if movie.user == request_user %} <a class="btn btn-warning" href="{% url 'update' movie.id %}">update</a> <a class="btn btn-danger" href="{% url 'delete' movie.id %}">Delete</a> {% endif %} </div> </div> </div> {% endblock %}
Charly
What can i change
exactly what I told you
-
exactly what I told you
I can’t understand
Charly
I can’t understand
https://t.me/django/269887
Charly
Which one
where you are using request.user
-
Ha it’s now working the buttons
-
But buttons showing for all users
Charly
Ha it’s now working the buttons
show again what you have done
-
{% extends 'base.html' %} {% block content %} <div class="container"> <div class="row"> <div class="col-md-6"> <img src="{{movie.poster.url}}" width="300" height="300"> </div> <div class="col-md-6"> <small>By: {{ user.username }}<br> {{user.id}} </small> <h6>Title:{{ movie.title }}</h6> <h6>Description:{{movie.description}}</h6> <h6>Trailer Link:{{movie.trailer_link}}</h6> <p>User: {{ user.username }}</p> <p>Movie User: {{ movie.user.username }}</p> {% if movie.user == request_user %} <a class="btn btn-warning" href="{% url 'update' movie.id %}">update</a> <a class="btn btn-danger" href="{% url 'delete' movie.id %}">Delete</a> {% endif %} </div> </div> </div> {% endblock %}
-
Only the user who added a movie can modify or delete it
All
has anybody created community forum with django ? Or work on something similar. I want to build something similar to reddit ? Are there libraries or anything that you might share that will accelerate my process.
🦅
Please share some source to learn django
🦅
For beginners
Rose
Please share some source to learn django
Looking for Django tutorials? you can follow these three recommended ones: * Official documentation and tutorial (https://docs.djangoproject.com/en/dev/intro/tutorial01/) * Tutorial from MDN (https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django) * Tutorial from django-girls (https://tutorial.djangogirls.org/en/)
Willi@m.
Hi guys, I'm having a hard time to understand the logic of follow and unfollow button in Django. Any tutorial that one recommend that can help please?
Noname
Hello everybody! I hope, you can give me advices. Are there any possibility to start/off crontab (periodic) tasks of Celery from Django code? I have a experimental way to lock code of crontab task by cache data (set from django views and read in celery tasks). But task anyway will be added tu queue, just without code executiuon. I want to lock adding to queue dinamically. Thans for your help!
Panther
Hello bros
Panther
Can anyone help me on the guide of installing tailwind css in django
Noname
Sergey M
Hello! There is a query: qs.annotate( hit_count=Case(*when_args, default=0), eff=Value(100)-F("hit_count") ) The result is this - https://pastebin.com/PTvQbrZA As you can see, the case/when expression is evaluated multiple times. Question: Is this normal behavior? Is it possible to calculate hit_count once and use it in subsequent annotations?
Rose
User Willi@​m.​ has 1/3 warnings; be careful! Reason: do not send PMs without the recipient's consent; ask the person in the group first (rule #9)
Khaydarov
#django #login i need to issue login api and i am trying to get token by TokenObtainPairSerializer().get_token(user) by filtering user from database but i am getting foreign key constraint failed error the interesting thing is that it works fine for one user, but the other user has the same error.
ali
Hello friends, how are you? For the filter part of the products, how can the page be refreshed when we click on a check box, and the related products will be returned. If someone wrote it in javascript, I would appreciate it if you could send me the code.
Rose
User Panther has 1/3 warnings; be careful! Reason: crossposting
Иван
Please tell me how I can remove the frame from the input in the standard registration form in the password field
Charly
Hello guys What is the best course on YouTube
The best thing to learn is not YouTube, is starting with the official documentation
Charly
If you want YouTube just use the search and sort by views
AB
The best thing to learn is not YouTube, is starting with the official documentation
Yeah but I want to take idea about Django first 9n YouTube
AB
On
Иван
What frame are you talking about?
I want to remove the outline of this field, this is the standard password form in the class BaseUserCreationform
.
Guys
.
Where I can study Django
.
For beginners
Rose
Where I can study Django
Looking for Django tutorials? you can follow these three recommended ones: * Official documentation and tutorial (https://docs.djangoproject.com/en/dev/intro/tutorial01/) * Tutorial from MDN (https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django) * Tutorial from django-girls (https://tutorial.djangogirls.org/en/)
Charly
Where I can study Django
Always go for the official docs for anything you want to learn
.
Thanks ☺️
Vishnu
I am working on an inventory project and I want to print the barcode directly to the zebra printer. How can I do that? Can someone help me with that. I will be adding a print button on the template, whenever the client clicks on the button. The label should be printed from the Zebra printer. How to do that?
(⌐■-■)
Hello all, is using firebase with django a good approach?
Charly
Hello all, is using firebase with django a good approach?
No, django is built on a relational model
(⌐■-■)
Owkyy
Rose
User Jibril has 1/3 warnings; be careful! Reason: rule #5 violation
Rose
User Jibril has 2/3 warnings; be careful! Reason: do not send PMs without the recipient's consent; ask the person in the group first (rule #9)
Arshia
hello guys I have a bug about django who can fix it ?
Charly
hello guys I have a bug about django who can fix it ?
Impossible to know the solution with no details at all