Come impostare il campo di lavoro predefinito in lettere minuscole? Questo è il mio modello:Modello Django - imposta il campo di lavoro predefinito in minuscolo
class User(models.Model):
username = models.CharField(max_length=100, unique=True)
password = models.CharField(max_length=64)
name = models.CharField(max_length=200)
phone = models.CharField(max_length=20)
email = models.CharField(max_length=200)
def __init__(self, *args, **kwargs):
self.username = self.username.lower()
Ho provato il __init__
ma non funziona. Voglio rendere il nome utente in minuscolo ogni volta che viene salvato un nuovo record. Grazie.
si può provare un tale http://stackoverflow.com/questions/2350681/django-lowercasecharfield – onerciller