mirror of
https://github.com/Fluffy-Bean/Fluffys-website.git
synced 2025-05-24 12:24:56 +00:00
Yeet docker!!!!
This commit is contained in:
parent
4394e713bd
commit
43665fb930
177 changed files with 31291 additions and 108 deletions
0
website/articles/__init__.py
Normal file
0
website/articles/__init__.py
Normal file
5
website/articles/admin.py
Normal file
5
website/articles/admin.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from django.contrib import admin
|
||||
from articles.models import Article
|
||||
|
||||
|
||||
admin.site.register(Article)
|
6
website/articles/apps.py
Normal file
6
website/articles/apps.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ArticlesConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "articles"
|
30
website/articles/migrations/0001_initial.py
Normal file
30
website/articles/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
# Generated by Django 4.2.2 on 2023-06-17 12:01
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
initial = True
|
||||
|
||||
dependencies = []
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="Article",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("title", models.CharField(max_length=255)),
|
||||
("slug", models.SlugField()),
|
||||
("body", models.TextField()),
|
||||
("date", models.DateTimeField(auto_now_add=True)),
|
||||
],
|
||||
),
|
||||
]
|
17
website/articles/migrations/0002_article_thumb.py
Normal file
17
website/articles/migrations/0002_article_thumb.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Generated by Django 4.2.2 on 2023-06-17 14:24
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("articles", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="article",
|
||||
name="thumb",
|
||||
field=models.ImageField(blank=True, default="default.png", upload_to=""),
|
||||
),
|
||||
]
|
17
website/articles/migrations/0003_alter_article_thumb.py
Normal file
17
website/articles/migrations/0003_alter_article_thumb.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Generated by Django 4.2.2 on 2023-06-17 14:34
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("articles", "0002_article_thumb"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="article",
|
||||
name="thumb",
|
||||
field=models.ImageField(blank=True, default="default.jpg", upload_to=""),
|
||||
),
|
||||
]
|
17
website/articles/migrations/0004_article_published.py
Normal file
17
website/articles/migrations/0004_article_published.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Generated by Django 4.2.2 on 2023-06-18 17:18
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("articles", "0003_alter_article_thumb"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="article",
|
||||
name="published",
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
17
website/articles/migrations/0005_alter_article_thumb.py
Normal file
17
website/articles/migrations/0005_alter_article_thumb.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Generated by Django 4.2.2 on 2023-06-19 16:44
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("articles", "0004_article_published"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="article",
|
||||
name="thumb",
|
||||
field=models.ImageField(blank=True, default="default.png", upload_to=""),
|
||||
),
|
||||
]
|
0
website/articles/migrations/__init__.py
Normal file
0
website/articles/migrations/__init__.py
Normal file
13
website/articles/models.py
Normal file
13
website/articles/models.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
from django.db import models
|
||||
|
||||
|
||||
class Article(models.Model):
|
||||
title = models.CharField(max_length=255)
|
||||
slug = models.SlugField()
|
||||
body = models.TextField()
|
||||
date = models.DateTimeField(auto_now_add=True)
|
||||
thumb = models.ImageField(default="default.png", blank=True)
|
||||
published = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
3
website/articles/tests.py
Normal file
3
website/articles/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
26
website/articles/urls.py
Normal file
26
website/articles/urls.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
"""
|
||||
URL configuration for website project.
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/4.2/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.urls import path
|
||||
from articles import views
|
||||
|
||||
|
||||
app_name = "articles"
|
||||
|
||||
urlpatterns = [
|
||||
path("", views.article_list, name="list"),
|
||||
path("<slug:slug>/", views.article_detail, name="detail"),
|
||||
]
|
20
website/articles/views.py
Normal file
20
website/articles/views.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
from django.shortcuts import render, get_object_or_404
|
||||
from django.http import HttpResponse
|
||||
from articles.models import Article
|
||||
|
||||
|
||||
def article_list(request):
|
||||
articles = (Article.objects.defer('body')
|
||||
.filter(published=True)
|
||||
.order_by("-date")
|
||||
.all())
|
||||
return render(request, "views/articles.html", {"articles": articles})
|
||||
|
||||
|
||||
def article_detail(request, slug):
|
||||
article = get_object_or_404(Article, slug=slug)
|
||||
|
||||
if not article.published:
|
||||
return HttpResponse("Not found")
|
||||
|
||||
return render(request, "views/article.html", {"article": article})
|
Loading…
Add table
Add a link
Reference in a new issue