Search code examples
python-3.xdjangopycharm

Pycharm doesn't see change in main.py when starting local server


  1. I created a project, added main to it for the main page in views and about, there are no errors, but the text is not displayed page
screenshot nothing changes at startup, but on the main page it writes page screenshot maybe I'm missing something? setting ![settings](https://i.sstatic.net/2hkmx.png] urls

page screenshot

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('main.urls'))
]

setting.py

    # Application definition

INSTALLED_APPS = [
    'main',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

views.py in main app

from django.shortcuts import render
from django.http import HttpResponse


def index(request):
    return HttpResponse("<h4>Hellow i'm main page</h4>")


def about(request):
    return HttpResponse('<h4>About as</h4>')

Urls.py in main app

from django.urls import path
from . import views
urlpatterns = [
    path('', views.index),
    path('about', views.about)
]

Solution

  • You forgot the trailing '/'. Don't worry it happened to me plenty of times when i started learning Django. It drove me crazy not knowing where the error was. :D

    Urls.py in the main app

    path('about/', views.about)
    

    Not

    path('about', views.about)