Questions tagged [django-request]

96 questions
0
votes
2 answers

How to get url params from the HttpRequest object

Suppose, we have a url path: path('something//test/', views.some_view) When a user hits this url, django makes an instance of HttpRequest, that will be passed to the some_view view. Is there a way to get the some_param url parameter…
Dmytro
  • 190
  • 8
0
votes
0 answers

Why is my django group showing an empty Queryset

I have this project and I want to be able to allow only members in a particular group to view it. But the problem is that in my admin panel, there are two groups there but when I run request.user.groups.all() I get an empty list? I'm using django…
0
votes
1 answer

content function in django.http source code

I was looking into below codes from Django Official Docs from django.http import HttpResponse import datetime def current_datetime(request): now = datetime.datetime.now() html = "It is now %s." % now return…
Yan Tian
  • 377
  • 3
  • 11
0
votes
1 answer

Django : pass session information to next template & view

I'm trying to build a little website where users can set up tournaments and then invite players for their tournaments. These are my Tournament and Invite models: class Tournament(models.Model): tourney_name = models.CharField(max_length=200,…
0
votes
1 answer

Django PUT/PATCH request body is empty in RetrieveUpdateAPIView

I'm trying to update user by passing Jwt token in header. But body of my request is empty. View passes empty data to serializer. views.py class UserRetrieveUpdateAPIView(RetrieveUpdateAPIView): permission_classes = (IsAuthenticated,) …
0
votes
2 answers

ValueError: Unable to configure filter "'request_id'"

I was trying to run the python3.8 manage.py runserver Im having the request_id defined in INSTALLED_APPS and request_id.middleware.RequestIdMiddleware added in MIDDLEWARE under setting.py This is the traceback > Exception ignored in thread started…
Vanjith
  • 520
  • 4
  • 23
0
votes
1 answer

How to Save Currently Logged in User to Model in Django

I am trying to get the currently logged in User and save it to a model. I am getting the following error "Cannot assign ">": "process_master.user" must be a "User" instance" I am using Django's built in user…
magicm
  • 3
  • 3
0
votes
0 answers

Storing redirect response in Django

I have a simple python function inside my Django app's views.py: def some_function(requests): return redirect('some_url') The redirect returns some useful information that I want to use later in the other function. Is there any way I can store the…
0
votes
2 answers

Django rest framework POST request: JSONDecodeError at /competition-create

Im trying to simply perform a post request that will save a new competition to the database. # views.py class CompetitionCreateView(generics.CreateAPIView): serializer_class = CompetitionSerializer queryset = Competition.objects.all() …
0
votes
3 answers

Passing user input to external link in django

I am trying to create a simple django site that would send information to another site with the requests.post function (I'm assuming that this is a correct method, but maybe there is a better way). So far I have a simple .html file created using…
A67John
  • 103
  • 7
0
votes
0 answers

Is it possible to pass an instance of a class defined in one view to another view in Django

Is it possible to pass an instance of a class defined in one view to another view in Django? I tried using session and am able to pass attributes but not able to pass a method. Ideally, I'd like to pass the class instance to session directly but I…
0
votes
1 answer

Assign currently LoggedIn user to ForeignKey field in Django

My problem is I cannot auto assign my logged in user in seller instance of my model. I have tried many solutions from stackoverflow but none of them worked. I dont know what the problem is. I have tried both class based view and function based view.…
0
votes
1 answer

How can i check if the function based view was called from another redirect function or directly from the url?

I have an online store where users pay at domain.com/pay and receive their product after paying at domain.com/done However, when I was testing it I found out that users can go to the URL and type domain.com/pay manually and all a sudden, they get…
user14340742
0
votes
1 answer

Django 2 Adding URL Parameter after {% url %} call in template

Without having to modify my urls.py, I want to manually add a URL parameter to the end of the {% url %} call in my template. Then, in my view, I want to access that query parameter's value. If lang='fr', open the French template or, if lang='en',…
earl
  • 3
  • 2
0
votes
0 answers

django change the default query set based on the requesting user

I have a system with multiple organizations logging in and interacting with us and our partners. I have a table that keeps track of what users have access to what organizations. I would like for customers to only see their own records. I am doing…