Adds Event form with start,end,place required

This commit is contained in:
2020-06-07 10:54:00 +00:00
parent 54516e4330
commit d2955be8e8
3 changed files with 29 additions and 16 deletions

View File

@@ -1,7 +1,7 @@
from django import forms
from ckeditor_uploader.widgets import CKEditorUploadingWidget
from .models import Post
from .models import Post, Event
class MyPostForm(forms.ModelForm):
class Meta:
@@ -12,6 +12,22 @@ class MyPostForm(forms.ModelForm):
class Media:
js = (
'js/auto_slug.js', # automatic slag completion ajax
'js/tag_completion.js',
'js/auto_slug.js', # automatic slag completion via ajax
'js/tag_completion.js', # to get a list for tag autocompletion via ajax
)
class MyEventForm(MyPostForm):
class Meta:
model = Event
fields = ['title','subtitle','tags', 'image','body',
'event_start','event_end', 'event_place','slug','author']
widgets = {'body': CKEditorUploadingWidget(config_name='default')}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) # to get the self.fields set
self.fields['event_start'].required = True
self.fields['event_end'].required = True
self.fields['event_place'].required = True