Sunday, September 1, 2019

Re: Call a URLpattern via POST from a Django view through HttpResponseRedirect

now i am hot

On Friday, June 14, 2019 at 4:15:51 AM UTC-7, Rohit Thapliyal wrote:
Here's the Django view:
def get_date(request):
    if request.method == 'POST':
        form = DateForm(request.POST)
        if form.is_valid():
            date = form.cleaned_data['date']
            print(type(date))
            return HttpResponseRedirect('schedule/{date}')

    else:
        form = DateForm()

    return render(request, 'app/date.html', {'form': form})

Here is the urls.py file:
from django.urls import path
from . import views

urlpatterns = [
    path('', views.get_date),
    path('schedule/<int: date>', views.get_slot),
]


I want to hit the date URL via the get_date view. But this results in error.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/670b9fef-8871-4a18-b452-c436d5422f34%40googlegroups.com.

No comments:

Post a Comment