Created
October 30, 2009 09:51
-
-
Save qingfeng/222240 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
from django.contrib import admin | |
from django import forms | |
from app1.models import * | |
from django.contrib.auth.models import User | |
class CustomForm(forms.ModelForm): | |
class Meta: | |
model = Data | |
def clean_d1(self): | |
if self.data["d1"]!="Chunjie Yanxu": | |
raise forms.ValidationError('d1必须输入Chunjie Yanxu') | |
return self.cleaned_data["d1"] | |
class DataAdmin(admin.ModelAdmin): | |
form = CustomForm | |
admin.site.register(Data, DataAdmin) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class Data(models.Model): | |
d1 = models.CharField(max_length=100) | |
d2 = models.CharField(max_length=100) | |
def __unicode__(self): | |
return self.d1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment