Questions tagged [django-request]

96 questions
1
vote
1 answer

Django Error: __init__() takes 1 positional argument but 2 were given

I am new to Django and I'm trying to create my first project following a tutorial from Udemy, but I encounter this error. My project has the following folder structure: -demo __…
1
vote
0 answers

How to enrich the Django request object with extended functions?

In my Django project, I have a situation where different views communicate via a request session data as follows: def view_one(request): ... request.session['my_session_key'] = data ... def view_two(request): ... data =…
1
vote
2 answers

How to get the path name of an URL in view?

I have urls paths with name in my urls.py file. urls.py urlpatterns = [ path('home/', views.home, name="home_view"), ] my views.py def home(request): path_name = get_path_name(request.path) return HttpResponse(path_name) Now, I need to…
rangarajan
  • 143
  • 5
  • 17
1
vote
2 answers

Failed to pass html input to django

I'm trying to pass date input to django python script in order to retrieve the data based on it. Here is my code. view def daily_usage_report(request): if request.method == 'POST': request_date = request.POST.get('request_date') …
Ricky
  • 53
  • 6
1
vote
1 answer

Why Is My Django Post Request Sending Incorrectly Parsed My List of Dictionaries?

Here is my Django view: def sendMail(request): url = 'https://example.com/example' dictwithlist = request.FILES['dictwithlist'] parsed = json.load(dictwithlist) // the log file shows that the lists are intact after json.loads …
Lester
  • 357
  • 3
  • 16
1
vote
1 answer

Doesn't Django's "request" only work when explicitly called?

That was my assumption. But there are examples like this one where: class PostDetailView(DetailView): model = Post template_name = 'blog/post.html' context_object_name = 'post' def get_context_data(self, **kwargs): context =…
YCode
  • 1,192
  • 1
  • 12
  • 28
1
vote
0 answers

How to Intercept and Modify / Alter a Django Request URL?

I have a search box. I search for: <- blank spaces in my search box. My form validation catches this. The URL shows: ++++++++++++++++ If I search for: The URL shows: