Commit 98aa801e authored by Ciella Francisco's avatar Ciella Francisco 😵

Updated Event Management views and URLs

parent 3e5730f3
from django.urls import path from django.urls import path
from .views import index from .views import event_view, EventListView, EventDetailView, EventCreateView, EventUpdateView
urlpatterns = [path('', index, name='index')] urlpatterns = [
path('', event_view, name='event'),
path('events/', EventListView.as_view(), name='event-list'),
path('<int:pk>/details', EventDetailView.as_view(), name='event-details'),
path('add/', EventCreateView.as_view(), name='event-create'),
path('<int:pk>/update', EventUpdateView.as_view(), name='event-update'),
]
app_name = "event_management" app_name = "event_management"
\ No newline at end of file
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
from django.views.generic.edit import CreateView, UpdateView
def index(request): from .models import Event
return HttpResponse('Hello World! This came from the index view.')
\ No newline at end of file def event_view(request):
events = Event.objects.all()
context = {'events' : events}
return render(request, 'event_management/events.html', context)
class EventDetailView(DetailView):
model = Event
template_name = 'event_management/event-details.html'
class EventListView(ListView):
model = Event
template_name = 'event_management/event-list.html'
class EventCreateView(CreateView):
model = Event
fields = '__all__'
template_name = 'event_management/event-create.html'
class EventUpdateView(UpdateView):
model = Event
fields = '__all__'
template_name = 'event/event-update.html'
\ No newline at end of file
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