18 lines
467 B
Python
18 lines
467 B
Python
|
from django import forms
|
||
|
from django.contrib.auth.hashers import make_password
|
||
|
from django.core.exceptions import ValidationError
|
||
|
|
||
|
from ..models.auth import APIUser
|
||
|
|
||
|
|
||
|
class APIUserForm(forms.ModelForm):
|
||
|
model = APIUser
|
||
|
fields = ["username", "password"]
|
||
|
|
||
|
def clean_password(self):
|
||
|
raw = self.cleaned_data['password']
|
||
|
|
||
|
if not raw:
|
||
|
return ValidationError("You did not enter a password.")
|
||
|
|
||
|
return make_password(raw)
|