#Beginner - Help with templates

1 messages · Page 1 of 1 (latest)

exotic chasm
#

That doesn't sound like official or recommended tutorial?

#

Anyway we need to know what you did and how it "isn't working"

gilded mulch
#

yea i thought i could add photos

#

I had to post them to imgur

exotic chasm
#

Please do NOT use photos

#

that is code, share it as formatted text

#

#readme-1st

gilded mulch
#

`{% load static %}

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>{% block title %} Homepage {% endblock %}</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="{% static 'css/style.css' %}">
</head>
<body>

    <header class="header">
        <a data-hover="Salut" href="{% url 'home' %}" class="nav-item">Home</a>
        <a data-hover="Salut" href="{% url 'photos' %}" class="nav-item">Photos</a>

    </header>

    {% block content %}
    {% endblock %}
    

</body>

</html>`
this is the base or the master html

#

and this is some other page
`{% extends 'master.html' %}

{% block content %}
<p>salut ionut</p>
{% endblock %} `

exotic chasm
#
{% load static %}

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>{% block title %} Homepage {% endblock %}</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="{% static 'css/style.css' %}">
    </head>
    <body>
        
        <header class="header">
            <a data-hover="Salut" href="{% url 'home' %}" class="nav-item">Home</a>
            <a data-hover="Salut" href="{% url 'photos' %}" class="nav-item">Photos</a>

        </header>

        {% block content %}
        {% endblock %}
        

    </body>
</html>
#

Looks right so far

gilded mulch
#

Yea that's what I'm saying, it's weird

exotic chasm
#

What exactly is weird? What you did with templates and what happened?

gilded mulch
#

Urls
`from django.contrib import admin
from django.urls import path
from photos import views

urlpatterns = [
path('admin/', admin.site.urls),
path('photos/', views.photos_list, name='photos'),
path('', views.home_page, name='home'),

]
`

#

Views
def home_page(request): return render(request, 'master.html')

#

So basically i just want to create a base html, with a navbar and footer

#

and then create other pages based on that base html

#

like components

#

wait a second

#

I think i got it

#

Nvm got it

#

forgot to change it in the urls

#

and views