django-request

Someone help me in this error TypeError at /contact 'method' object is not subscriptable

Someone help me in this error TypeError at /contact 'method' object is not subscriptable Question: Views.py # Create your views here. def home(request): return render(request, ‘home.html’) def about(request): return render(request, ‘about.html’) def project(request): return render(request, ‘project.html’) def contact(request): if request.method==’POST’: name=request.POST.get[‘name’] email=request.POST.get[’email’] phone=request.POST.get[‘phone’] concern=request.POST.get[‘concern’] print(name,email,phone,’concern’) obj=Contact(name=’name’, email=’email’,phone=’phone’,concern=’concern’) obj.save() return render(request, ‘contact.html’) I am trying to …

Total answers: 1

How do I get the JWT tokens from user in Django RestFramework

How do I get the JWT tokens from user in Django RestFramework Question: I have a DRF project using Simple-JWT for authentication. When a user logs in, they get a response containing the access and refresh tokens in the serializer.data. However: When testing on the Apis I can manually copy and paste these tokens and …

Total answers: 1

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

How to get the path name of an URL in view? Question: 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 get the path name, "home_view" in the HttpResponse. How can I make …

Total answers: 3