Commit fb4a5bfc authored by Julia Anishka's avatar Julia Anishka

updated views, url and created template for add new announcement page

parent e2232aac
{% extends 'base.html' %}
{% block title %} Add Announcement {% endblock %}
{% block header %}
<h1> Add a new announcement: </h1>
{% endblock %}
{% block body %}
<form method='POST'>
{% csrf_token %}
{{ form }}
<input type="Submit" value="Add Announcement">
</form>
{% endblock %}
\ No newline at end of file
from django.urls import path from django.urls import path
from . import views from . import views
from .views import (AnnouncementsCreateView,
)
urlpatterns = [ urlpatterns = [
path('', views.announcement_view, name='announcements'), path('', views.announcement_view, name='announcements'),
path('announcements/add/', AnnouncementsCreateView.as_view(), name='announcement-add'),
] ]
from django.http import HttpResponse from django.http import HttpResponse
from django.shortcuts import render from django.shortcuts import render
from django.views.generic.edit import CreateView
from .models import Announcement, Reaction from .models import Announcement, Reaction
def announcement_view(request): def announcement_view(request):
...@@ -9,3 +11,8 @@ def announcement_view(request): ...@@ -9,3 +11,8 @@ def announcement_view(request):
'announcements': announcements 'announcements': announcements
} }
return render(request, 'announcementboard/announcements.html', context) return render(request, 'announcementboard/announcements.html', context)
class AnnouncementsCreateView(CreateView):
model = Announcement
template_name = 'announcementboard/announcement-add.html'
fields = '__all__'
\ 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