233👍
You are probably requesting the URL without a trailing slash, and have APPEND_SLASH
set to True (the default) in settings.py, so Django is redirecting to the URL including a slash.
6👍
So for me, it was a combination of the following:
SecurityMiddleware
enabledSECURE_SSL_REDIRECT = True
- Separate Web Server had SSL redirect enabled as well
In that case, the web server already does the redirecting and forwards the request via HTTP to Django, which then redirects again to HTTPS which ends in an infinite loop.
So, in that case, it’s safe to set SECURE_SSL_REDIRECT = False
.
- [Django]-Django test runner not finding tests
- [Django]-How to add superuser in Django from fixture
- [Django]-How to serve media files on Django production environment?
5👍
My problem was PREPEND_WWW, when using it in localhost it returns a 301 error, I just created a local settings file and set it PREPEND_WWW = False
- [Django]-Identify the changed fields in django post_save signal
- [Django]-Django: Safely Remove Old Migrations?
- [Django]-Django Model Field Default to Null
3👍
In my case, commenting the SecurityMiddleware on the settings.py
file did the trick. I have to say that this only happens when running the runserver
command (aka. when testing). With Apache it doesn’t falls into the redirect loop.
- [Django]-Python/Django: log to console under runserver, log to file under Apache
- [Django]-In a Django QuerySet, how to filter for "not exists" in a many-to-one relationship
- [Django]-What's the idiomatic Python equivalent to Django's 'regroup' template tag?
0👍
When using postman everything was working okay but when i was requesting it from the frontend i was getting the 301 error. You are probably missing the trailing slash in the url, i had the same problem and i solved it by adding the slash to the url….
- [Django]-How to limit columns returned by Django query?
- [Django]-Gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3> django
- [Django]-Django models: mutual references between two classes and impossibility to use forward declaration in python
-1👍
Yes, please check URL you may be missing slash some where.
I fixed this by adding slash at the end of URL
- [Django]-How does Django's nested Meta class work?
- [Django]-How to understand lazy function in Django utils functional module
- [Django]-Django. A good tutorial for Class Based Views