From c9a032236e68472c1ba2497396084e0242c38fbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Thu, 21 Sep 2017 19:58:42 +0200 Subject: [PATCH] Fix `Publication`'s fields --- mainsite/admin.py | 4 +++- mainsite/migrations/0001_initial.py | 6 ++++-- mainsite/models.py | 13 ++++++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/mainsite/admin.py b/mainsite/admin.py index 8c38f3f..9d4fa1e 100644 --- a/mainsite/admin.py +++ b/mainsite/admin.py @@ -1,3 +1,5 @@ from django.contrib import admin +from . import models -# Register your models here. + +admin.site.register(models.Publication) diff --git a/mainsite/migrations/0001_initial.py b/mainsite/migrations/0001_initial.py index f0cf0fd..d7ab41e 100644 --- a/mainsite/migrations/0001_initial.py +++ b/mainsite/migrations/0001_initial.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.11.5 on 2017-09-21 09:34 +# Generated by Django 1.11.5 on 2017-09-21 17:57 from __future__ import unicode_literals from django.db import migrations, models @@ -18,9 +18,11 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('num', models.CharField(max_length=128, verbose_name='Numéro du BOcal')), - ('url', models.URLField(verbose_name='Adresse sur le site')), + ('url', models.CharField(max_length=512, verbose_name='Adresse sur le site')), ('date', models.DateField(verbose_name='Publication')), ('is_special', models.BooleanField(default=False, help_text='Numéro du BOcal non-numéroté', verbose_name='Numéro spécial')), + ('descr', models.CharField(blank=True, max_length=512, verbose_name='Description (optionnelle)')), + ('custom_name', models.CharField(blank=True, help_text='Vide pour laisser le numéro seulement', max_length=128, verbose_name='Nom customisé')), ], ), ] diff --git a/mainsite/models.py b/mainsite/models.py index e3701b7..1d8a070 100644 --- a/mainsite/models.py +++ b/mainsite/models.py @@ -1,22 +1,25 @@ from django.db import models -from django.db.models import URLField, \ - DateField, \ +from django.db.models import DateField, \ CharField, \ BooleanField class Publication(models.Model): num = CharField('Numéro du BOcal', max_length=128) - url = URLField('Adresse sur le site') + url = CharField('Adresse sur le site', max_length=512) + # ^ This is not a URLField because we need internal URLS, eg `/static/blah` + date = DateField('Publication') is_special = BooleanField('Numéro spécial', help_text='Numéro du BOcal non-numéroté', default=False) descr = CharField('Description (optionnelle)', - max_length=512), + max_length=512, + blank=True) custom_name = CharField('Nom customisé', help_text='Vide pour laisser le numéro seulement', - max_length=128), + max_length=128, + blank=True) def __str__(self): if self.custom_name: