Davis Keene Davis Keene - 1 year ago 58
Python Question

Trouble loading Django App after testing other Django App for several days? Always redirects to requested URL that doesn't exist?

Over the weekend I attended a hackathon, at which I created a Django app that ran on on my local machine with

python manage.py runserver

Today, I tried to launch another Django app that I had made in the past for bug fixes and things, but when I ran manage.py runserver it keeps redirecting me to, even though it's a totally separate app.

Anyone know how to resolve this issue?

urls.py for Django app that I'm trying to run:

from django.conf.urls import url
from TweeTest import views

urlpatterns = [
url(r'^$', views.view_home, name='home'),
url(r'^about/$', views.AboutPageView.as_view()),
url(r'^contact/$', views.ContactPageView.as_view()),
url(r'^result/$', views.view_tweet, name = 'result'),


urls.py for Django app I made over the weekend:

from django.conf.urls import include, url
from django.conf import settings
from django.conf.urls.static import static
from django.views.generic import RedirectView

from django.contrib import admin

urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^myapp/', include('myproject.myapp.urls')),
url(r'^$', RedirectView.as_view(url='/myapp/list/', permanent=True)),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Is it something to do with the RedirectView line in the second urls.py?

I'm not sure why a totally different Django app is trying to connect to the same URL as the other one... seems strange.

If someone knows the answer to this, that would be greatly appreciated!



When I try to connect to on incognito mode, it works fine. Could this mean it's a browser issue?


Answer Source

permanent=True sends a HTTP 301 Permanent redirect to the browser. Browsers tend to cache 301 responses very aggressively, meaning your web browser currently remembers that is a permanent redirect to Since your browser doesn't know that different Django apps might be running on at different times, it always follows the cached redirect.

You shouldn't use permanent=True unless you know what you are doing. While it can boost the performance on a high-traffic site, it is rarely necessary for low- to medium-traffic sites, and the permanent caching can be a real pain for developers.

Either clear your browser cache, run your Django test server on a different port, or use a different browser.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download