How to expire Django session in 5minutes?

There are two parameters to expire sessions, SESSION_EXPIRE_AT_BROWSER_CLOSE and SESSION_COOKIE_AGE. If you want to expire in 5 minutes yours settings should like as: SESSION_EXPIRE_AT_BROWSER_CLOSE = False SESSION_COOKIE_AGE = 5 * 60 To combine both learn how do it writing your custom middleware “Is there a way to combine behavior of SESSION_EXPIRE_AT_BROWSER_CLOSE and SESSION_COOKIE_AGE”

Django – is not a registered namespace

You should just change you action url in your template: <form action=”{% url ‘submit’ %} “method=’post’> On the note of url namespaces… In order to be able to call urls using home namespace you should have in your main urls.py file line something like: for django 1.x: url(r’^’, include(‘home.urls’, namespace=”home”)), for django 2.x and 3.x … Read more

Django request to find previous referrer

That piece of information is in the META attribute of the HttpRequest, and it’s the HTTP_REFERER (sic) key, so I believe you should be able to access it in the template as: {{ request.META.HTTP_REFERER }} Works in the shell: >>> from django.template import * >>> t = Template(“https://stackoverflow.com/questions/4406377/{{ request.META.HTTP_REFERER }}”) >>> from django.http import HttpRequest … Read more

Django test RequestFactory vs Client

RequestFactory and Client have some very different use-cases. To put it in a single sentence: RequestFactory returns a request, while Client returns a response. The RequestFactory does what it says – it’s a factory to create request objects. Nothing more, nothing less. The Client is used to fake a complete request-response cycle. It will create … Read more

ValueError: Missing staticfiles manifest entry for ‘favicon.ico’

Try running: python manage.py collectstatic Does the test work now? If so, this might be the configuration causing a problem: STATICFILES_STORAGE = ‘whitenoise.django.GzipManifestStaticFilesStorage’ as of whitenoise v4 this will fail and you should use: STATICFILES_STORAGE = ‘whitenoise.storage.CompressedManifestStaticFilesStorage’ Related: https://stackoverflow.com/a/32347324/2596187 Check out the Django documentation: https://docs.djangoproject.com/en/1.11/ref/contrib/staticfiles/#django.contrib.staticfiles.storage.ManifestStaticFilesStorage.manifest_strict