from django.db import models from django.db.models import URLField, \ DateField, \ CharField, \ BooleanField class Publication(models.Model): num = CharField('Numéro du BOcal', max_length=128) url = URLField('Adresse sur le site') 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), custom_name = CharField('Nom customisé', help_text='Vide pour laisser le numéro seulement', max_length=128), def __str__(self): if self.custom_name: return self.custom_name return 'BOcal n°{}'.format(self.num)