I hosted my Django app on AWS with Nginx, gunicorn and Postgres. Now I got 3 issues
- Django changes not reflecting
- Style not working
- CSRF Failed: CSRF token missing while post a request
Style not working
I added STATIC_URL = '/static/' , STATIC_ROOT = os.path.join(BASE_DIR, 'static') on settings.py and + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) on urls.py.
CSRF Failed: CSRF token missing while post a request
And I'm not using Django rest framework default authentication But I'm using just my own logic. Here is it
@csrf_exempt
@api_view(['POST'])
def student_login(request):
if request.method == 'POST':
name = request.data['name']
password= request.data['password']
try:
user_obj = Admission.objects.get(name = name, password = password)
return Response({"Token": user_obj.student_token}, status=status.HTTP_200_OK)
except Admission.DoesNotExist:
return Response({"Error": "Invalid username or password!"}, status=status.HTTP_400_BAD_REQUEST)
return Response({"Error": "Somthing went wrong!"}, status=status.HTTP_400_BAD_REQUEST)

