首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Django forms在IE7中突破

Django forms在IE7中突破
EN

Stack Overflow用户
提问于 2010-08-27 22:24:24
回答 1查看 436关注 0票数 6

我从一个模型得到了一个带有错误检查(有效的电子邮件字段等)的dJango webform。除了IE7,一切都可以在Opera,Camino,Netscape,Safari和IE浏览器中正常运行。

我在IE7上看到的只是一条“Internet Explorer无法显示网页”的消息。如果表单有效,数据就会写入数据库,所以我认为这与重定向阶段有关。

我尝试过method=get和javascript表单提交的各种方法,但似乎没有什么能阻止IE7给我这个错误。

任何帮助都将不胜感激。

forms.py

代码语言:javascript
运行
复制
class NewElectiveForm(ModelForm):  
    host_country    = forms.CharField(widget=forms.widgets.Select(choices=COUNTRIES) , label="Destination")
    host_type       = forms.CharField(widget=forms.widgets.Select(choices=HOST_TYPE) , label="Location type")      
    host_name       = forms.CharField(max_length=256, label="Name of host institution")
    host_street     = forms.CharField(required = False, max_length=100, label="Street")
    host_city       = forms.CharField(required = False, max_length=100, label="City") 
    host_district   = forms.CharField(required = False, max_length=100, label="District")
    host_zipcode    = forms.CharField(required = False, max_length=100, label="Zipcode")
    host_supervisor = forms.CharField(required = False, max_length=256, label="Name of supervisor")
    host_email      = forms.EmailField(required = False, max_length=100, label="Email")
    host_fax        = forms.CharField(required = False, max_length=100, label="Fax.No.")
    host_tel        = forms.CharField(required = False, max_length=100, label="Tel.No.")
    start_date      = forms.DateField(widget=SelectDateWidget(),label="Elective start date")   
    end_date        = forms.DateField(widget=SelectDateWidget(),label="Elective end date")   
    subject         = forms.CharField(required = False, max_length=256,label="Subject")
    reasons         = forms.CharField(required = False, widget=forms.widgets.Textarea(attrs={'class':'question'}),   label="Please state briefly the reasons for this choice's location and subject")
    outcomes        = forms.CharField(required = False, widget=forms.widgets.Textarea(attrs={'class':'question'}), label="Please give upto to 4 outcomes that you hope to achieve during this elective")
    your_mobile     = forms.CharField(required = False, max_length=100,  label="Please provide your mobile number if you are taking it with you")        
    insurance       = forms.BooleanField(required = False, label="Please confirm that you have arranged holiday insurance")
    malpractice     = forms.BooleanField(required = False, label="Please confirm that you have medical malpractice cover")
    groupinfo       = forms.CharField(required = False, label="If you planning your Elective in a group, please list your fellow students") 
    #risk_upload = forms.FileField(widget=AdminFileWidget, required = False, label='Upload a completed risk assesment form')
    #evidence_upload = forms.FileField(widget=AdminFileWidget, required = False, label='Upload an evidence document')


    class Meta:
            model = ElectiveRecord        
            exclude = ('id', 'review','elective', 'status', 'edit_userid','modified')

html模板:

代码语言:javascript
运行
复制
<form  enctype="multipart/form-data" method="post" class="uniForm" id="newform" >
   {% for i in form %}
   <div class="fieldwrapper {% for error in i.errors %} error {% endfor %}">
 {% for error in i.errors %}
   <b>{{error|escape}}</b><br/> 
 {% endfor %}
 {{ i.label_tag }} :
  {% if i.html_name == "reasons" or  i.html_name == "outcomes" %} <br/> {% endif %}
 {{ i }}
 {% if i.html_name == "evidence_upload" %} <br/>latest file= xxx {% endif %}
        {% if i.html_name == "risk_upload" %} <br/>latest file= xxx {% endif %}
 </div>  
    {%endfor%} 
    <div class="fieldWrapper"> <input type="submit" value="Save" NAME='save'   > </div>
</form>

models.py

代码语言:javascript
运行
复制
class ElectiveRecord(models.Model):
        elective        = models.ForeignKey(Elective, null=True, blank=True)  
        status          = models.CharField(choices=ELECTIVE_STATUS_FLAGS, max_length=40)
        edit_date       = models.DateTimeField(auto_now_add=True)        
        edit_userid     = models.CharField(max_length=12)
        host_country    = models.CharField(max_length=100, help_text="Destination")
        host_type       = models.CharField(choices=HOST_TYPE, max_length=10, help_text="Location type")      
        host_name       = models.CharField(max_length=256, help_text="Name of host institution")
        host_street     = models.CharField(max_length=100, help_text="Street")
        host_city       = models.CharField(max_length=100, help_text="City") 
        host_district   = models.CharField(max_length=100, help_text="District")
        host_zipcode    = models.CharField(max_length=100, help_text="Zipcode")
        host_supervisor = models.CharField(max_length=256, help_text="Name of supervisor")
        host_email      = models.CharField(max_length=100, help_text="Email")
        host_fax        = models.CharField(max_length=100, blank=True, help_text="Fax.No.")
        host_tel        = models.CharField(max_length=100, help_text="Tel.No.")
        start_date      = models.DateField(help_text="Elective start date")   
        end_date        = models.DateField(help_text="Elective end date")   
        subject         = models.CharField(max_length=256,help_text="Tel.No.")
        reasons         = models.TextField(help_text="Please state briefly the reasons for this choice's location and subject")
        outcomes        = models.TextField(help_text="Please give upto to 4 outcomes that you hope to achieve during this elective")
        your_mobile     = models.CharField(max_length=100, blank=True, help_text="Please provide your mobile number if you are taking it with you")        
        insurance       = models.BooleanField(default=False, help_text="Please confirm that you have arranged holiday insurance")
        malpractice     = models.BooleanField(default=False, help_text="Please confirm that you have medical malpractice cover")
        groupinfo       = models.CharField(max_length=256, blank=True, help_text="If you planning your Elective in a group, please list your fellow students") 
        modified        = models.DateTimeField(auto_now_add=True)        
        class Meta:
              get_latest_by = 'modified'        
        def __unicode__(self):
                return u"[%s] %s, %s  " % (self.id,self.host_name,self.subject)
EN

回答 1

Stack Overflow用户

发布于 2010-08-28 03:18:46

确认是重定向阶段导致了问题,方法是替换

代码语言:javascript
运行
复制
HttpResponseRedirect(url)

使用

代码语言:javascript
运行
复制
HttpResponse('<!DOCTYPE html><html><head><title>title</title></head><body><a href="%(url)s">%(url)s</a></body></html>' % {'url':url})

如果这没有呈现,那么问题就发生在重定向之前。如果它确实呈现了,那么问题可能是重定向,也可能是重定向的页面。单击该链接。如果下一页显示正确,几乎可以肯定问题出在重定向本身。否则,问题出在重定向的页面上。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3585102

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档