There are two kinds of ways to make redirection.
1. Function based view
2. Class based view
1. Functiom based View
First, you need to make a function having request as the first parameter, and I put *args and **kwargs just in case.
The function is going to connect with urls.py as a view.
2. Class based view
class KirrRedirectView(View):
def get(self, request, *args, **kwargs):
return HttpResponse("Hello again")
Class based view has inheritance of View from django.views
And you need to declare 'get' method which also has request.
The get method is for 'GET' request.
One thing you need to keep in mind is as_view(). When you use class based view, you need to use as_view() method to connect the class with URL.
Django with Docker (0) | 2021.01.15 |
---|---|
Relationship between URLS and VIEWS (0) | 2020.10.29 |
Set Global Variable using settings.py (0) | 2020.10.29 |
Django Architecture (0) | 2020.10.29 |
댓글 영역