Create Class View instead of normal simple view.
class views:
---
from django.views import View
class Another(View):
def get(self,request):
return HttpResponse('This is another function inside class')
#normal view
def first(request):
return HttpResponse('First message from Views')
urls.py in app:
--
from . import views
from .views import Another
urlpatterns=[
path('first',views.first)
path('another',Another.as_view())
]
No comments:
Post a Comment