mirror of
https://github.com/DerTyp7/tealcode-django-python.git
synced 2025-10-30 20:57:07 +01:00
added models
This commit is contained in:
@@ -1,10 +1,36 @@
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import render, redirect
|
||||
from .models import Category, Topic
|
||||
|
||||
def index(req):
|
||||
return render(req, "main/index.html")
|
||||
|
||||
def topic(req, category, topic):
|
||||
return render(req, "main/topic.html")
|
||||
|
||||
if topic and category:
|
||||
category_obj = Category.objects.filter(title = category).first()
|
||||
if category_obj:
|
||||
topic_obj = Topic.objects.filter(title=topic, category = category_obj).first()
|
||||
if topic_obj:
|
||||
context = {
|
||||
'title': topic_obj.title,
|
||||
'code': topic_obj.code_text,
|
||||
'category_title': category_obj.title,
|
||||
}
|
||||
|
||||
return render(req, "main/topic.html", context)
|
||||
|
||||
return redirect("main-index")
|
||||
|
||||
|
||||
|
||||
def category(req, category):
|
||||
return render(req, "main/category.html")
|
||||
|
||||
if category:
|
||||
category_obj = Category.objects.filter(title = category).first()
|
||||
if category_obj:
|
||||
return render(req, "main/category.html", {'category_obj': category_obj})
|
||||
|
||||
|
||||
return redirect("main-index")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user