我有以下基于模型的表格。
class Article(models.Model):
title = models.CharField(max_length=100, db_column='title')
url = models.CharField(max_length=100, db_column='url')
category = models.ForeignKey(Category, db_column='category')
description = models.TextField(db_column='description')
createDate = models.DateTimeField(db_column='createDate')
def __unicode__(self):
return self.title
class Meta:
db_table = 'articles'
ordering = ['createDate']
形式
class ArticleForm(forms.ModelForm):
class Meta:
model = Article
fields = ('title', 'description', 'category')
我想要的是通过小写已清理的标题来验证表单并更改 url 的值。我怎样才能做到这一点?我似乎认为 url 是排除值,那么如何在验证后在表单中更改它?
谢谢。