amélioration du formulaire de saisie

This commit is contained in:
Jean-Marie Favreau 2023-10-29 15:01:16 +01:00
parent 7bd7d1e500
commit 817f0a317e
5 changed files with 43 additions and 2 deletions

View File

@ -1,6 +1,21 @@
from django.contrib import admin
from django import forms
from .models import Event, EventSubmissionForm, Category
from django_better_admin_arrayfield.admin.mixins import DynamicArrayMixin
from django_better_admin_arrayfield.forms.widgets import DynamicArrayWidget
from django_better_admin_arrayfield.models.fields import DynamicArrayField
admin.site.register(Event)
admin.site.register(EventSubmissionForm)
admin.site.register(Category)
class URLWidget(DynamicArrayWidget):
def __init__(self, *args, **kwargs):
kwargs['subwidget_form'] = forms.URLField()
super().__init__(*args, **kwargs)
@admin.register(Event)
class Eventdmin(admin.ModelAdmin, DynamicArrayMixin):
formfield_overrides = {
DynamicArrayField: {'urls': URLWidget},
}

View File

@ -0,0 +1,24 @@
# Generated by Django 4.2.1 on 2023-10-29 13:51
from django.db import migrations, models
import django_better_admin_arrayfield.models.fields
class Migration(migrations.Migration):
dependencies = [
('agenda_culturel', '0007_event_category_event_tags'),
]
operations = [
migrations.AlterField(
model_name='event',
name='reference_urls',
field=django_better_admin_arrayfield.models.fields.ArrayField(base_field=models.URLField(max_length=512), blank=True, help_text='List of all the urls where this event can be found.', null=True, size=None, verbose_name='URLs'),
),
migrations.AlterField(
model_name='event',
name='tags',
field=django_better_admin_arrayfield.models.fields.ArrayField(base_field=models.CharField(max_length=64), blank=True, help_text='A list of tags that describe the event.', null=True, size=None, verbose_name='Tags'),
),
]

View File

@ -1,5 +1,5 @@
from django.db import models
from django.contrib.postgres.fields import ArrayField
from django_better_admin_arrayfield.models.fields import ArrayField
from django.utils.translation import gettext_lazy as _
from django.template.defaultfilters import slugify # new
from django.urls import reverse

View File

@ -38,6 +38,7 @@ INSTALLED_APPS = [
"agenda_culturel",
"colorfield",
'django_extensions',
'django_better_admin_arrayfield',
]
MIDDLEWARE = [

View File

@ -27,3 +27,4 @@ django-colorfield==0.10.1
cffi==1.16.0
django-extensions==3.2.3
djipsum==1.1.5
django-better-admin-arrayfield==1.4.2