""" | """ | ||||
from django.contrib import admin | from django.contrib import admin | ||||
from django.urls import path, include | from django.urls import path, include | ||||
from. import views | |||||
urlpatterns = [ | urlpatterns = [ | ||||
path('', include('posts.urls')), | |||||
path('', views.index, name="index"), | |||||
path('posts/', include('posts.urls')), | path('posts/', include('posts.urls')), | ||||
path('admin/', admin.site.urls), | path('admin/', admin.site.urls), | ||||
] | ] |
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') |
# 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 | from django.db import migrations, models | ||||
from . import views | from . import views | ||||
urlpatterns = [ | urlpatterns = [ | ||||
path('', views.index, name='index') | |||||
path('', views.index, name='posts') | |||||
] | ] |
from django.http import HttpResponse | from django.http import HttpResponse | ||||
from .models import Notice | from .models import Notice | ||||
from django.utils import timezone | 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. | # Create your views here. | ||||
def index(request): | def index(request): | ||||
init_loger() | |||||
notices = Notice.objects.all() | 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 = { | context = { | ||||
"notices": notices, | "notices": notices, | ||||
} | } |
<a class="nav-link" href="{% url 'index' %}">Home</a> | <a class="nav-link" href="{% url 'index' %}">Home</a> | ||||
</li> | </li> | ||||
<li class="nav-item"> | <li class="nav-item"> | ||||
<a class="nav-link" href="{% url 'index' %}">Posts</a> | |||||
<a class="nav-link" href="{% url 'posts' %}">Posts</a> | |||||
</li> | </li> | ||||
<li class="nav-item"> | <li class="nav-item"> | ||||
<a class="nav-link" href="https://www.th-nuernberg.de/fakultaeten/efi/">EFI</a> | <a class="nav-link" href="https://www.th-nuernberg.de/fakultaeten/efi/">EFI</a> |
{% 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 %} |