Commit 792cebf9 authored by Charles Lim's avatar Charles Lim

Set up URLs with new cbv

parent 85d51030
......@@ -13,7 +13,5 @@
{% endblock %}
{% block content %}
<p> Student ID: {{object.id_num}}</p>
<p> Email: {{object.email}}</p>
<p> Department and Course: {{object.department.home_unit}}, {{object.department.dept_name}}</p>
{{form.as_p}}
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import HomepageView, WidgetUserDetailView
from .views import HomepageView, WidgetUserDetailView, WidgetUserCreateView
urlpatterns = [
path('', HomepageView.as_view(), name='index'),
path('<int:pk>/details', WidgetUserDetailView.as_view(),
name='widgetuser_detail'),
path('users/add', WidgetUserCreateView.as_view(),
name='widgetuser_form'),
]
app_name = "homepage"
......@@ -5,7 +5,7 @@ from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView
from .models import WidgetUser
# Homepage Index View
class HomepageView(View):
def get(self, request):
objects_set = {
......@@ -13,10 +13,12 @@ class HomepageView(View):
}
return render(request, 'homepage/index.html', objects_set)
# WidgetUser Detail View
class WidgetUserDetailView(DetailView):
model = WidgetUser
# WidgetUser Create View
class WidgetUserCreateView(CreateView):
model = WidgetUser
fields = ["first_name", "middle_name", "last_name",
"id_num", "email", "profile_pic", "department"]
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