0

Over the weekend I attended a hackathon, at which I created a Django app that ran on 127.0.0.1:8000/myapp/list 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 127.0.0.1:8000/myapp/list, 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!

Thanks!

UPDATE:

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

Davis

Davis Keene
  • 213
  • 1
  • 5
  • 12

2 Answers2

1

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 http://127.0.0.1:8000/ is a permanent redirect to http://127.0.0.1:8000/myapp/list/. Since your browser doesn't know that different Django apps might be running on 127.0.0.1:8000 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.

Mathias Rav
  • 2,808
  • 14
  • 24
0

Have you tried using a different browser or clearing your browser history? This sounds like a browser issue to me.

spooky
  • 106
  • 1
  • 5