def site_events(request, event_id=None): event = get_object_or_404(SiteEvent, pk=event_id) if event_id else None data = request.POST or None if event: form = SiteEventForm(data, instance=event) else: form = SiteEventForm(data) if request.method == 'POST' and form.is_valid(): form.save() return redirect('zadmin.site_events') pager = amo.utils.paginate(request, SiteEvent.objects.all(), 30) events = pager.object_list return render(request, 'zadmin/site_events.html', { 'form': form, 'events': events})