Browse Source

Merge first migration

devel
Lennart Heimbs 4 years ago
parent
commit
e77bf697f3

+ 2
- 1
news/news/urls.py View File

@@ -15,9 +15,10 @@ Including another URLconf
"""
from django.contrib import admin
from django.urls import path, include
from. import views

urlpatterns = [
path('', include('posts.urls')),
path('', views.index, name="index"),
path('posts/', include('posts.urls')),
path('admin/', admin.site.urls),
]

+ 15
- 0
news/news/views.py View File

@@ -0,0 +1,15 @@
from django.shortcuts import render
from django.http import HttpResponse

logger = None

def init_loger():
global logger
if not logger:
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler)

# Create your views here.
def index(request):
return render(request, 'news/index.html')

+ 1
- 1
news/posts/migrations/0001_initial.py View File

@@ -1,4 +1,4 @@
# Generated by Django 2.2.7 on 2019-11-19 10:39
# Generated by Django 2.2.6 on 2019-11-19 12:29

from django.db import migrations, models


+ 1
- 1
news/posts/urls.py View File

@@ -2,5 +2,5 @@ from django.urls import path
from . import views

urlpatterns = [
path('', views.index, name='index')
path('', views.index, name='posts')
]

+ 12
- 2
news/posts/views.py View File

@@ -2,12 +2,22 @@ from django.shortcuts import render
from django.http import HttpResponse
from .models import Notice
from django.utils import timezone
import logging

logger = None

def init_loger():
global logger
if logger == None:
logger = logging.getLogger('django.db.backends')
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler())

# Create your views here.
def index(request):
init_loger()
notices = Notice.objects.all()
notices = Notice.objects.filter(pub_start__lte=timezone.now())
notices = Notice.objects.filter(pub_end__gte=timezone.now())
notices = Notice.objects.filter(pub_start__lte=timezone.now(), pub_end__gte=timezone.now())
context = {
"notices": notices,
}

+ 1
- 1
news/templates/navbar.html View File

@@ -6,7 +6,7 @@
<a class="nav-link" href="{% url 'index' %}">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'index' %}">Posts</a>
<a class="nav-link" href="{% url 'posts' %}">Posts</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://www.th-nuernberg.de/fakultaeten/efi/">EFI</a>

+ 13
- 0
news/templates/news/index.html View File

@@ -0,0 +1,13 @@
{% extends 'base.html' %}

{% block title %}
Index
{% endblock %}

{% block content %}
<div class="jumbotron">
<h1 class="display-4">Index of News App</h1>

<p class="lead">Some placeholder Text</p>
</div>
{% endblock %}

Loading…
Cancel
Save