Hi , Thinks for the new Django 1.2.

I just try the 1.2 , if tag and multiple databases is very good.

But I have a problem use the old code(run ok in 1.1) like this:

class articleDB(models.Model):
    user = models.ForeignKey(User,related_name='article_user') #文章作者
    myclass = models.ForeignKey(articleBoard,verbose_name=u'栏
目',related_name='article_class') #文章所属板块
    ip = models.IPAddressField()

    title = models.CharField(u'标题',max_length=200)
    reload_url = models.CharField(u'跳转
到',max_length=200,null=True,blank=True)
    content = models.TextField(u'内容',null=True,blank=True)

    review  = models.BooleanField(u'发布')
    viewnum = models.IntegerField(u'阅读次数',default=0)
    created = models.DateTimeField(u'发表时间', auto_now_add = True)
    updated = models.DateTimeField(u'修改时间', auto_now = True)

class articleForm(ModelForm):
    class Meta:
        model = articleDB
        exclude = ('user','review','viewnum','ip')

def new(request):
    if request.method == 'POST':
        data = request.POST.copy()
        form = articleForm(data)

        if form.is_valid():
            new_do = form.save(commit=False)
            new_do.user = request.user
            new_do.ip = request.META['REMOTE_ADDR']
            new_do.save()
            return redirect("/user/")
    else:
        form = articleForm()
    board_list = articleBoard.objects.filter
(myclass__isnull=True).order_by('id')
    extra_context = {'board_list':board_list,'form':form}
    return render_to_response
('article_new.html',extra_context,RequestContext(request))

when I submit the error is :

UnresolvableValidationError at /article/new/
{'ip': [u'\u8fd9\u4e2a\u503c\u4e0d\u80fd\u4e3a null\u3002'], 'user':
[u'\u8fd9\u4e2a\u503c\u4e0d\u80fd\u4e3a null\u3002']}

I don't know why?
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to