Debugging not working in VS Studio Code Django

I have been working through the official Django Tutorial in Visual Studio Code but I have run into an issue. Currently when I ever I set a break point at the line now = datetime.now the debugger seems to fail reach it. Attached it my urls.py code and my view.py code.

from django.urls import path
from hello import views

urlpatterns = [
path("", views.home, name="home"),
path("hello/<name>", views.hello_there, name="hello_there"),
]

Above is the urls.py code. Below is the views.py code.

import re
from django.utils.timezone import datetime
from django.http import HttpResponse

def home(request):
    return HttpResponse("Hello, Django!")

def hello_there(request, name):
    now = datetime.now()
    formatted_now = now.strftime("%A, %d %B, %Y at %X")

    # Filter the name argument to letters only using regular expressions. URL arguments
    # can contain arbitrary text, so we restrict to safe characters only.
    match_object = re.match("[a-zA-Z]+", name)

    if match_object:
        clean_name = match_object.group(0)
    else:
        clean_name = "Friend"

    content = "Hello there, " + clean_name + "! It's " + formatted_now
    return HttpResponse(content)

I apologize if the formatting is off, I am a beginner and new to stack overflow.

Source: Python Questions

LEAVE A COMMENT