Commit eb68ea90 authored by MJoshBen's avatar MJoshBen

Implemented Add New Announcement Page

parent 77dbe756
{% extends 'base.html' %}
{% block title %}Add Announcement{% endblock %}
{% block content %}
<h1>Add a new announcement:</h1><br>
<form action="" method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save New Announcement">
</form>
{% endblock %}
{% block scripts %}
{% endblock %}
from django.contrib import admin
from django.urls import path
from .views import index, AnnouncementDetailView
from .views import index, AnnouncementDetailView, AnnouncementCreateView
urlpatterns = [
path('', index, name='index'),
path('<int:pk>/details', AnnouncementDetailView.as_view(), name='announcement-details')
path('<int:pk>/details', AnnouncementDetailView.as_view(), name='announcement-details'),
path('add/', AnnouncementCreateView.as_view(), name='add-announcement')
]
app_name = "announcement"
from django.shortcuts import render
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView
from .models import Announcement, Reaction
from .models import Announcement
def index(request):
return render(request, 'announcement/announcement.html', {'announcement': Announcement.objects.all()})
......@@ -12,3 +13,8 @@ class AnnouncementDetailView(DetailView):
def get(self, request, pk):
return render(request, 'announcement/announcement-details.html', {'announcement': self.model.objects.get(pk=pk)})
class AnnouncementCreateView(CreateView):
model = Announcement
fields = '__all__'
template_name = 'announcement/announcement-add.html'
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