diff --git a/.idea/dataSources.local.xml b/.idea/dataSources.local.xml new file mode 100644 index 0000000..3fb2d21 --- /dev/null +++ b/.idea/dataSources.local.xml @@ -0,0 +1,9 @@ + + + + + + false + + + \ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml new file mode 100644 index 0000000..ea0aa11 --- /dev/null +++ b/.idea/dataSources.xml @@ -0,0 +1,14 @@ + + + + + sqlite.xerial + true + org.sqlite.JDBC + jdbc:sqlite:C:\Users\vivek\Desktop\eventify_prod\db.sqlite3 + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index e35e137..cfc8f1e 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,12 +2,9 @@ + - - - - + + + + @@ -251,7 +220,7 @@ - + - + @@ -283,13 +260,13 @@ - + - + @@ -297,15 +274,13 @@ - - - - @@ -324,9 +299,6 @@ - - - @@ -429,16 +401,6 @@ - - - - - - - - - - @@ -486,13 +448,6 @@ - - - - - - - @@ -529,15 +484,6 @@ - - - - - - - - - @@ -545,32 +491,12 @@ - + - - + + - - - - - - - - - - - - - - - - - - - - - + @@ -582,15 +508,69 @@ - + + + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/accounts/forms.py b/accounts/forms.py index 8895ed2..cfb9b89 100644 --- a/accounts/forms.py +++ b/accounts/forms.py @@ -4,13 +4,28 @@ from django.contrib.auth.forms import AuthenticationForm from .models import User from django import forms +from django import forms +from django.contrib.auth.models import User + + +class UserForm(forms.ModelForm): + password = forms.CharField(widget=forms.PasswordInput) + + class Meta: + model = User + fields = ["username", "email", "password"] -class UserForm(AuthenticationForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) for field in self.fields.values(): field.widget.attrs.update({"class": "form-control"}) + def form_valid(self, form): + user = form.save(commit=False) + user.set_password(form.cleaned_data['password']) + user.save() + return super().form_valid(form) + class LoginForm(AuthenticationForm): username = forms.CharField( diff --git a/templates/accounts/user_form.html b/templates/accounts/user_form.html index 4dfe5c2..a2f8faa 100644 --- a/templates/accounts/user_form.html +++ b/templates/accounts/user_form.html @@ -1,7 +1,7 @@ {% extends 'base.html' %} {% block content %}
-

{% if object %}Edit{% else %}Add{% endif %} Event

+

{% if object %}Edit{% else %}Add{% endif %} User

{% csrf_token %}