Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
red_brick_board
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ciella Francisco
red_brick_board
Commits
544894fe
Commit
544894fe
authored
Apr 13, 2024
by
Ciella Francisco
😵
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Included formset in models.py for multiple image upload in Event model
parent
f6bae834
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
17 deletions
+22
-17
forms.py
redbrickboard/event_management/forms.py
+22
-17
No files found.
redbrickboard/event_management/forms.py
View file @
544894fe
from
accounts
import
models
as
accounts
from
django
import
forms
from
django.forms
import
ModelForm
from
.models
import
Event
# class EventForm(forms.ModelForm):
# class Meta:
# model = Event
# fields = ["event_name", "event_datetime_start", "event_datetime_end", "event_organizer", "event_header", "last_time_bumped"]
from
django.forms
import
ModelForm
,
BaseModelFormSet
,
inlineformset_factory
from
.models
import
Event
,
Promo
class
EventForm
(
ModelForm
):
# event_name = forms.CharField(label='Event Name', max_length=150)
# event_datetime_start = forms.DateTimeField(label='Event Start Date and Time')
# event_datetime_end = forms.DateTimeField(label='Event End Date and Time')
# event_organizer = forms.ModelChoiceField(label='Event Organizer', queryset=accounts.CustomUser.objects.all())
# event_header = forms.ImageField(label='Event Header Photo')
# last_time_bumped = forms.DateTimeField(label='Last Time Bump')
class
Meta
:
model
=
Event
fields
=
"__all__"
# fields = ["event_name", "event_datetime_start", "event_datetime_end",
# "event_organizer", "event_header", "last_time_bumped"]
# fields = ["event_datetime_start"]
widgets
=
{
'event_datetime_start'
:
forms
.
TextInput
(
attrs
=
{
'type'
:
'datetime-local'
}),
'event_datetime_end'
:
forms
.
TextInput
(
attrs
=
{
'type'
:
'datetime-local'
}),
'last_time_bumped'
:
forms
.
TextInput
(
attrs
=
{
'type'
:
'datetime-local'
}),
}
\ No newline at end of file
}
class
PromoForm
(
ModelForm
):
model
=
Promo
fields
=
"__all__"
# Source for the whole formset integration:
# https://www.letscodemore.com/blog/django-inline-formset-factory-with-examples/
PromoFormSet
=
inlineformset_factory
(
Event
,
Promo
,
form
=
PromoForm
,
extra
=
1
,
fields
=
[
'img'
],
can_delete
=
True
,
can_delete_extra
=
True
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment