2016-08-12 36 views
0

當我將我的渲染到forms.py我的HTML文件不符合(響應)完全在屏幕上Django的引導形式不適合在html頁面

forms.py -

class RegisterUserForm(forms.Form): 
     username = forms.CharField(min_length=6, widget=forms.TextInput(attrs={'class': 'form-control'})) 
     email = forms.EmailField(widget=forms.EmailInput(attrs={'class': 'form-control'})) 
     password = forms.CharField(min_length=8, widget=forms.PasswordInput(attrs={'class': 'form-control'})) 
     password2 = forms.CharField(widget=forms.PasswordInput(attrs={'class': 'form-control'})) 
     photo = forms.ImageField(required=True) 

如果我嘗試該網站沒有形式,頁面適應屏幕,但是當我添加的形式是「{{form.as_p}}」,不工作

HTML頁面 -

<div class="panel panel-default"> 
<div class="panel-heading"> 
    <h2>User Register</h2> 
</div> 
<div class="panel-body"> 
<div class="row"> 
    <div class="col-md-6 col-sm-offset-3"> 
    <form role="form" action="" method="post"> 
     {% csrf_token %} 
     {{form.as_p}} 
    </form> 
    </div> 
</div> 
<button type="submit" name="register" class="btn btn-primary"><span class="glyphicon glyphicon-log-in"></span> Register</button> 
</div> 
<div class="panel-footer"> 
</div> 
</div> 

我需要一切都是適應性的,我該如何去做呢?

pic1 pic2

+0

其他,我敢肯定你的問題,也涉及到了' col-sm-offset「,你不應該真的需要面板內的網格 – Sayse

回答

1

插入此代碼頭:

不是重複的,這將給修復此不同的方式
<meta name="viewport" content="width=device-width, initial-scale=1">