password1 = forms.CharField(widget=forms.PasswordInput(attrs={'placeholder': 'password'}))
server {
listen 80 default_server;
listen [::]:80 default_server;
return 444;
}
server {
listen 80;
listen [::]:80;
server_name vashdomain.com;
error_page 403 /error/404.html;
error_page 404 /error/404.html;
error_page 500 502 503 504 /error/50x.html;
location / {
proxy_pass http://127.0.0.1:4567;
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_cache_bypass $http_upgrade;
}
}
def get_serializer_class(self):
print(self.request.method)
if hasattr(self.request, 'method'):
if self.request.method == 'GET':
return StepResultSerializer
if self.request.method == 'POST':
return StepInputSerializer
def get_serializer_class(self):
if self.request.method == 'GET':
return StepResultSerializer
else:
return StepInputSerializer
from rest_framework.authentication import SessionAuthentication
class CsrfExemptSessionAuthentication(SessionAuthentication):
def enforce_csrf(self, request):
return None
class AddingSomething(GenericAPIView):
permission_classes = (permissions.AllowAny, )
serializer_class = AddSomethingSerializer
authentication_classes = (CsrfExemptSessionAuthentication,)
queryset = None
def post(self, request, **kwargs):
# .. Some magic ..
return HttpResponseRedirect(redirect_to=reverse('something_added'))