Merge first migration
This commit is contained in:
commit
e77bf697f3
@ -15,9 +15,10 @@ Including another URLconf
|
|||||||
"""
|
"""
|
||||||
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),
|
||||||
]
|
]
|
||||||
|
15
news/news/views.py
Normal file
15
news/news/views.py
Normal 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,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
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
@ -2,5 +2,5 @@ from django.urls import path
|
|||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.index, name='index')
|
path('', views.index, name='posts')
|
||||||
]
|
]
|
@ -2,12 +2,22 @@ from django.shortcuts import render
|
|||||||
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_start__lte=timezone.now(), pub_end__gte=timezone.now())
|
||||||
notices = Notice.objects.filter(pub_end__gte=timezone.now())
|
|
||||||
context = {
|
context = {
|
||||||
"notices": notices,
|
"notices": notices,
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<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>
|
||||||
|
13
news/templates/news/index.html
Normal file
13
news/templates/news/index.html
Normal 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…
x
Reference in New Issue
Block a user