added post to admin.py and fixed css

This commit is contained in:
Esther Kleinhenz 2018-07-15 15:27:10 +02:00
parent 666b5e909a
commit 65188e033e
6 changed files with 34 additions and 7 deletions

View File

@ -1,3 +1,5 @@
from django.contrib import admin
from .models import Post
admin.site.register(Post)
# Register your models here.

View File

@ -0,0 +1,20 @@
# Generated by Django 2.0.6 on 2018-07-15 12:30
from django.db import migrations
import taggit.managers
class Migration(migrations.Migration):
dependencies = [
('taggit', '0002_auto_20150616_2121'),
('application', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='post',
name='tags',
field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'),
),
]

View File

@ -6,7 +6,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title> {% block title %}Seitenname{% endblock %}</title>
<link href="{% static 'css/mysite.css' %}" rel="stylesheet">
<link href="{% static 'css/application.css' %}" rel="stylesheet">
<link href="{% static 'bootstrap/css/bootstrap.css' %}" rel="stylesheet">
</head>
@ -76,8 +76,13 @@
</div>
</nav>
<div class="content container">
<div class="row">
<div class="col-md-8">
{% block content %} {% endblock %}
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="{% static 'bootstrap/js/bootstrap.bundle.js' %}"></script>
</body>

View File

@ -35,13 +35,13 @@ def navlogin(request):
context = {'error': error}
return render(request, 'index.html', context)
@login_required
def post_list(request):
posts = Post.objects.filter(
published_date__lte=timezone.now()).order_by('published_date')
return render(request, 'post_list.html', {'posts': posts})
@login_required
def post_detail(request, pk):
post = get_object_or_404(Post, pk=pk)
return render(request, 'post_detail.html', {'post': post})

View File

@ -43,8 +43,8 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'taggit',
'application',
'taggit',
]
MIDDLEWARE = [

View File

@ -23,8 +23,8 @@ import application.views
urlpatterns = [
url(r'^$', TemplateView.as_view(template_name="index.html")),
url(r'^admin/', admin.site.urls),
url(r'^navlogin/', application.views.navlogin, name='navlogin'),
url(r'^accounts/', include('django.contrib.auth.urls')),
url(r'', include('application.urls'))
]