Commit c645e472 authored by Ciella Francisco's avatar Ciella Francisco 😵

Simplified and removed unnecessary blocks of code in CreateView within event_management views.py

parent b804aa8b
...@@ -19,21 +19,8 @@ class EventListView(ListView): ...@@ -19,21 +19,8 @@ class EventListView(ListView):
class EventCreateView(CreateView): class EventCreateView(CreateView):
model = Event model = Event
fields = '__all__' form_class = EventForm
success_url = '/events/'
def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
context = super().get_context_data(**kwargs)
context['form'] = EventForm()
return context
def post(self, request, *args, **kwargs):
form = EventForm(request.POST)
if form.is_valid():
return self.get(request, *args, **kwargs)
else:
return render(request, self.template_name, {'form': form})
template_name = 'event_management/event-form.html' template_name = 'event_management/event-form.html'
class EventUpdateView(UpdateView): class EventUpdateView(UpdateView):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment