topics.html not displayed in my browser

my deposal directory for my html files is C:\learning_log\learning_logs\templates\learning_log
Directory of C:\learning_log\learning_logs\templates\learning_logs
base.html
index.html
topics.html

#  My topics.html

{% extends “learning_logs/base.html” %}

{% block content %}

Topics

{% for topic in topics %}* {{ topic }}
{% empty %}* No topics have been added yet.
{% endfor %}

{% endblock content %}

My views.py

""" From learning_log/learning_logs """
from django.shortcuts import render
from .models import Topic
# Create your views here.

def index(request):
    """ the home page from learning_log """
    return render(request, 'learning_logs/index.html')

#def topics(request):
#    """show all topics"""
#    topics = Topic.objects.order_by('date_added')   #date_added
#    context = {'topics':topics}
#    return render(request,'learning_logs/topics.html', context)

# ADD test 01/01/2024
def topics(request):
    """show all topics"""
    topics = Topic.objects.order_by('date_added')
    print(topics)  # Add this line for debugging
    context = {'topics': topics}
   # return render(request, 'templates/learning_logs/topics.html', context)
    return render(request, 'learning_logs/topics.html', context)

#The runserver find the data requested (200)

C:\learning_log>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks…

System check identified no issues (0 silenced).
January 02, 2024 - 21:52:08
Django version 3.2.18, using settings ‘learning_log.settings’
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
<QuerySet [<Topic: Topic 1>, <Topic: Topic 2>]>
[02/Jan/2024 21:52:23] “GET /topics/ HTTP/1.1” 200 86

but the display on my browser is

[learning_logs](http://127.0.0.1:8000/) - [topics](http://127.0.0.1:8000/topics/)" }‘’’

Chrome

#My setting.py contain

TEMPLATES = [
{
‘BACKEND’: ‘django.template.backends.django.DjangoTemplates’,
‘DIRS’: ,
‘APP_DIRS’: True,
‘OPTIONS’: {
‘context_processors’: [
‘django.template.context_processors.debug’,
‘django.template.context_processors.request’,
‘django.contrib.auth.context_processors.auth’,
‘django.contrib.messages.context_processors.messages’,
],
}
}
]

Sseams that the data base is working fine

C:\learning_log>python manage.py shell
Python 3.11.1 (tags/v3.11.1:a7a450f, Dec 6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
(InteractiveConsole)

> > > from learning_logs.models import Topic
> > > first_topic = Topic.objects.first()
> > > print(first_topic)
> > > Topic 1
> > > specific_topic = Topic.objects.get(id=1)
> > > print(specific_topic)
> > > Topic 1 

Seams that django does not find his views.py to display the informations to the browser screen

It’s hard to tell here in the copy that you’ve pasted here, but it looks like you might have “smart quotes” around the template name in the extends block.

Verify that your version of the template doesn’t have these types of characters in it.

It appears that your template configuration might be incorrect. The ‘DIRS’ key is expecting a corresponding value. Assign an empty list to ‘DIRS’ and provide the path to your template. This adjustment should resolve the issue you’re facing.

if you have the template folder in your project directory pass the value like this:

'DIRS': [BASE_DIR / 'templates']

and if you create template folder in your app directory your just give an empty list like this:

'DIRS': []

Django will automatically looked into your app directory.

I see in my base.html

<p>
<a href="{% url 'learning_logs:index' %}">learning_logs</a> -
<a href="{% url 'learning_logs:topics'  %}">topics</a>"           }
</p>

I will correct it into

<p>
<a href="{% url 'learning_logs:index' %}">learning_logs</a> -
<a href="{% url 'learning_logs:topics'  %}">topics</a>"           
</p>

still the same problem

I will correct m directory has proposed by Amnar

in my setting.py is now the description of the TEMPLATES

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

The templates are located in c:\learning_log\learning_logs\templates\learning_logs\(here is the location of the base.html ; index.html ; topics.html

I will try to change  'DIRS' : []    TO 'DIRS': [BASE_DIR / 'templates']

![runserver-browser|690x314](upload://nNkRBsc8migblHs29oyWHMFBBpC.png)

Like the with the first test  'DIRS' : []    every time that I click in the "topics" from the browser window there is a reaction in the runserver   :
<QuerySet [<Topic: Topic 1>, <Topic: Topic 2>]>
[03/Jan/2024 20:17:15] "GET /topics/ HTTP/1.1" 200 86   so there are a transmission of data .

I will test with  'DIRS': [BASE_DIR / 'templates/learning_logs'  because the HTML are there located

it's the same behavior !!!!!  I will look if django is really looking in the directory c:\learning_log\learning_logs\templates\learning_logs\(here is the location of the base.html ; index.html ; topics.html  with changing the name od the HTML into old_name.html

It's the goed directory because now I get

TemplateDoesNotExist at /topics/
learning_logs/topics.html
Request Method:	GET
Request URL:	http://127.0.0.1:8000/topics/
Django Version:	3.2.18
Exception Type:	TemplateDoesNotExist
Exception Value:	
learning_logs/topics.html
Exception Location:	C:\Users\EALALIN\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\template\loader.py, line 19, in get_template
Python Executable:	C:\Users\EALALIN\AppData\Local\Programs\Python\Python311\python.exe
Python Version:	3.11.1
Python Path:	
['C:\\learning_log',
 'C:\\Users\\EALALIN\\AppData\\Local\\Programs\\Python\\Python311\\python311.zip',
 'C:\\Users\\EALALIN\\AppData\\Local\\Programs\\Python\\Python311\\Lib',
 'C:\\Users\\EALALIN\\AppData\\Local\\Programs\\Python\\Python311\\DLLs',
 'C:\\Users\\EALALIN\\AppData\\Roaming\\Python\\Python311\\site-packages',
 'C:\\Users\\EALALIN\\AppData\\Local\\Programs\\Python\\Python311',
 'C:\\Users\\EALALIN\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages']
Server time:	Wed, 03 Jan 2024 19:37:37 +0000

#I reverse like it was ‘DIRS’: and give the originale name back to my HML files.
it’s the same behavior.

base.html

<p>
<a href="{% url 'learning_logs:index' %}">learning_logs</a> -
<a href="{% url 'learning_logs:topics'  %}">topics</a>"           }
</p>

hum I see the same error has before I delete the }

#base.html

<p>
<a href="{% url 'learning_logs:index' %}">learning_logs</a> -
<a href="{% url 'learning_logs:topics'  %}">topics</a>"           
</p>

#index.html

{% extends "learning_logs/base.html" %}

{% block content %}
<p>learning_logs helps you keep track of your learning, for topic you 're learning about. </p>
{% endblock content %}

#topics.html

{% extends "learning_logs/base.html" %}

{% block content %}

<p>Topics</p>
<ul>
    {% for topic in topics %}
     <li>{{ topic }}</li>
         {% empty %} 
     <li> No topics have been added yet.</li>
     {% endfor %}  
</ul>
{% endblock content %}

I’m kind of lost here.

What specifically is the problem that you’re trying to resolve? Everything I’m seeing makes sense with what you’ve posted, to the degree I’m able to determine.

Blockquote I have not the information’s showed in the browser

Please do not repost your earlier response. I’m asking you for a specific description of what you are seeing that you are not expecting to see (or what you’re expecting to see that isn’t there.) Please do not just post code or templates. Identify the issue to be resolved.

ok now it’s your reply window who open , it was not the case just before.
with the C:\learning_log>python manage.py runserver running
when from my browser (google chrome) when I call the link (http://127.0.0.1:8000/topics/)
I will to see the results display on the browser screen .
the only that I get is

learning_logs - topics"
not in this form but like this

sorry but I get problem with thr reply windows

Ok, so if I understand you correctly, you’re expecting to see a list of topics, but all you’re seeing is the header.

If so:

Is this the complete base.html file?

ok I understant ,I have to compleet this HTML file correct?

I’m asking you if what you’ve posted here is the entire file, or if there is more in that file that you did not include in your post.

I was busy with the views.py

I have on github all the programme on ealalin (ealalin) / Repositories · GitHub (learning_log) it’s open to public view

Or do you prefer to have the file in this post ?

Ok, so that is the complete file.

You have in your topics.html:

This means that topics.html is going to define blocks that will replace the corresponding blocks in the base template - your base.html file.

However, your base.html file does not define a block named content into which topics.html will place the content being rendered. You need to define a {% block content %} and {% endblock content %} in your base template.

Ken thankx very much for your amaziing support , amazing because your are all the time available .

Best regards