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

Set up URLs with new cbv

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