Browse Source

added post to admin.py and fixed css

newsletter
Esther Kleinhenz 6 years ago
parent
commit
65188e033e

+ 2
- 0
application/admin.py View File

from django.contrib import admin from django.contrib import admin
from .models import Post


admin.site.register(Post)
# Register your models here. # Register your models here.

+ 20
- 0
application/migrations/0002_post_tags.py View File

# 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'),
),
]

+ 8
- 3
application/templates/base.html View File

<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title> {% block title %}Seitenname{% endblock %}</title> <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"> <link href="{% static 'bootstrap/css/bootstrap.css' %}" rel="stylesheet">
</head> </head>


</div> </div>
</nav> </nav>


{% block content %} {% endblock %}

<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="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="{% static 'bootstrap/js/bootstrap.bundle.js' %}"></script> <script src="{% static 'bootstrap/js/bootstrap.bundle.js' %}"></script>
</body> </body>

+ 2
- 2
application/views.py View File

context = {'error': error} context = {'error': error}
return render(request, 'index.html', context) return render(request, 'index.html', context)


@login_required
def post_list(request): def post_list(request):
posts = Post.objects.filter( posts = Post.objects.filter(
published_date__lte=timezone.now()).order_by('published_date') published_date__lte=timezone.now()).order_by('published_date')
return render(request, 'post_list.html', {'posts': posts}) return render(request, 'post_list.html', {'posts': posts})


@login_required
def post_detail(request, pk): def post_detail(request, pk):
post = get_object_or_404(Post, pk=pk) post = get_object_or_404(Post, pk=pk)
return render(request, 'post_detail.html', {'post': post}) return render(request, 'post_detail.html', {'post': post})

+ 1
- 1
mysite/settings.py View File

'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'taggit',
'application', 'application',
'taggit',
] ]


MIDDLEWARE = [ MIDDLEWARE = [

+ 1
- 1
mysite/urls.py View File





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

Loading…
Cancel
Save