Add templates & static files

This commit is contained in:
Nyymix 2024-12-28 14:14:21 +02:00
parent 1bcf7ceba3
commit 043449cf4f
8 changed files with 55 additions and 8 deletions

View file

@ -55,7 +55,7 @@ ROOT_URLCONF = 'config.urls'
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [], 'DIRS': [BASE_DIR / "templates"],
'APP_DIRS': True, 'APP_DIRS': True,
'OPTIONS': { 'OPTIONS': {
'context_processors': [ 'context_processors': [
@ -117,6 +117,9 @@ USE_TZ = True
# https://docs.djangoproject.com/en/5.1/howto/static-files/ # https://docs.djangoproject.com/en/5.1/howto/static-files/
STATIC_URL = 'static/' STATIC_URL = 'static/'
STATICFILES_DIRS = [
BASE_DIR / 'static',
]
# Default primary key field type # Default primary key field type
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field # https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field

View file

@ -14,10 +14,15 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path 1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
""" """
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin from django.contrib import admin
from django.urls import include, path from django.urls import include, path
urlpatterns = [ urlpatterns = [
path("gallery/", include("gallery.urls")), path("", include("gallery.urls")),
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
] ]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

View file

@ -0,0 +1,9 @@
{% extends "base.html" %}
<!-- Title -->
{% block title %} Galleria {% endblock %}
<!-- Content -->
{% block content %}
Hello World!
{% endblock %}

View file

@ -5,5 +5,6 @@ from . import views
app_name = 'gallery' app_name = 'gallery'
urlpatterns = [ urlpatterns = [
path("", views.index, name="index"), path('', views.Main.as_view(), name='main_url'),
] ]

View file

@ -1,9 +1,8 @@
from django.http import HttpResponse
from django.shortcuts import render from django.shortcuts import render
from django.views.generic import TemplateView
# Create your views here. # Create your views here.
class Main(TemplateView):
def index(request): template_name = "gallery/main.html"
return HttpResponse("Hello, world.")

3
static/css/muistox.css Normal file
View file

@ -0,0 +1,3 @@
body {
font: 400 14px/20px "Helvetica Neue",Helvetica,Arial,sans-serif;
}

2
static/js/muistox.js Normal file
View file

@ -0,0 +1,2 @@

25
templates/base.html Normal file
View file

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
{% load static %}
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Muistox CSS -->
<link href="{% static 'css/muistox.css' %}" rel="stylesheet">
<title>{% block title %} Gallery {% endblock %}</title>
</head>
<body>
<!-- Main -->
<main class="uk-align-center uk-container-large">
{% block content %} No Content {% endblock %}
</main>
<!-- Muistox JS -->
<script src="{% static 'js/muistox.js' %}" type="text/javascript"></script>
</body>
</html>