Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
from django.contrib.auth.forms import UserCreationForm from django.core.exceptions import ValidationError from django.utils.translation import gettext_lazy as _ from django.contrib.auth import get_user_model UserModel = get_user_model() class MyHolidayUserCreationForm(UserCreationForm): user = None def clean_password1(self): password1 = self.cleaned_data.get("password1") self.validate_password(password1) return password1 def validate_password(self, password): if len(password) < 6: raise ValidationError(_("Password must be at least 6 characters long.")) has_letter = False has_digit = False has_underscore = False for char in password: if char.isalpha(): has_letter = True elif char.isdigit(): has_digit = True elif char == '_': has_underscore = True if not has_letter: raise ValidationError(_("Password must contain at least one letter.")) if not has_digit: raise ValidationError(_("Password must contain at least one digit.")) if not has_underscore: raise ValidationError(_("Password must contain at least one underscore.")) class Meta(UserCreationForm.Meta): model = UserModel fields = ('email',)
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)