django bootstrap3
使用其实很方便。
1. install bootstrap3
pip install django-bootstrap3
try import bootstrap3
2. Add to INSTALLED_APPS in your settings.py:
'bootstrap3',
3. Load the bootstrap3 library and use the bootstrap_* tags:
{# Load the tag library #}
{% load bootstrap3 %}
{# Load CSS and JavaScript #}
{% bootstrap_css %}
{% bootstrap_javascript %}
{# Display django.contrib.messages as Bootstrap alerts #}
{% bootstrap_messages %}
{# Display a form #}
<form action="/url/to/submit/" method="post" class="form">
{% csrf_token %}
{% bootstrap_form form %}
{% buttons %}
<button type="submit" class="btn btn-primary">
{% bootstrap_icon "star" %} Submit
</button>
{% endbuttons %}
</form>
{# Read the documentation for more information #}
表单还是具体的表单,用点bootstrap* 的东西修饰一下就行了。还是挺方便的。
值得注意的是bootstrap 他默认是屏幕自适应的,需要用div 标签限制一下。
<div style="width:200px">
完整的项目可以参考我的gitlab
git@github.com:gqdw/bootstrap_test.git