Commit 50c552c3 authored by Anya Habana's avatar Anya Habana

Created new user form template

parent f4f0fa08
from django.forms import ModelForm from django.forms import ModelForm
from .models import WidgetUser from .models import WidgetUser
class WidgetUserForm(forms.Form): class WidgetUserForm(ModelForm):
class Meta: class Meta:
model = WidgetUser model = WidgetUser
fields = ["first_name", "middle_name", "last_name", "id_num", "email", "department"] fields = ["first_name", "middle_name", "last_name", "id_num", "email", "department"]
\ No newline at end of file
<form action="{% url 'homepage:newuser' %}" method="POST">
{% csrf_token %}
{{ user_form }}
<<button class="button" type="submit">Save New User</button>
</form>
\ No newline at end of file
...@@ -21,7 +21,7 @@ def newuser(request): ...@@ -21,7 +21,7 @@ def newuser(request):
return redirect("homepage:index", pk=new_user.pk) return redirect("homepage:index", pk=new_user.pk)
else: else:
user_form = WidgetUserForm() user_form = WidgetUserForm()
return render(request, 'newuser.html', {"user_form": user_form}) return render(request, 'users/newuser.html', {"user_form": user_form})
class WidgetUserDetailView(DetailView): class WidgetUserDetailView(DetailView):
model = WidgetUser model = WidgetUser
......
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