Catégories affichées dans la navbar.

This commit is contained in:
Klafyvel 2018-01-24 11:44:54 +01:00
parent 9c82cb8ee7
commit 21c1a5719b
4 changed files with 30 additions and 1 deletions

View file

@ -0,0 +1,23 @@
# Generated by Django 2.0.1 on 2018-01-24 10:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('content', '0001_initial'),
]
operations = [
migrations.RemoveField(
model_name='category',
name='Nom de la catégorie',
),
migrations.AddField(
model_name='category',
name='name',
field=models.CharField(default='Nom de la catégorie', max_length=255, verbose_name='Nom de la catégorie'),
preserve_default=False,
),
]

View file

@ -6,7 +6,7 @@ class Category(models.Model):
"""Une catégorie de contenu.""" """Une catégorie de contenu."""
name = models.CharField( name = models.CharField(
max_length=255, max_length=255,
name="Nom de la catégorie" verbose_name="Nom de la catégorie"
) )

View file

@ -2,6 +2,7 @@ from django.urls import path
from .views import ContentCategoryList from .views import ContentCategoryList
app_name = 'content'
urlpatterns = [ urlpatterns = [
path( path(
'category/<int:category_id>/', 'category/<int:category_id>/',

View file

@ -1,3 +1,5 @@
{% load categories %}
{% load_categories %}
<nav class="navbar navbar-default navbar-inverse"> <nav class="navbar navbar-default navbar-inverse">
<div class="container-fluid"> <div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display --> <!-- Brand and toggle get grouped for better mobile display -->
@ -15,6 +17,9 @@
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li> <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
{% for category in categories %}
<li><a href="{% url 'content:category-list' category_id=category.id %}">{{category.name}}</a></li>
{% endfor %}
<li><a href="">Vote</a></li> <li><a href="">Vote</a></li>
<li class="dropdown"> <li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>