使用Django 1.8,Python 3.4和Bootstrap 3,表格呈現,但缺少grid/css(見下圖)。是否與django1.8和bootstrap3一起使用django-tables2?
我已經安裝Django的tables2每docs我也跑collecstatic(本地主機)它也出現在我的virtualenv django1834 /靜態/ django_tables2 /主題/ paleblue/CSS
任何幫助/建議將不勝感激
#的settings.py
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.core.context_processors.request',
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
...
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
#的views.py
from django_tables2 import RequestConfig
from cdpapp.tables import WorkOrderTable
...
def list_all_workorders(request):
table = WorkOrderTable(WorkOrder.objects.all())
RequestConfig(request).configure(table)
return render(request, 'cdpapp/workorder_all_list.html', {'table': table})
#tables.py
import django_tables2 as tables
from django_tables2.utils import A # alias for Accessor
from cdpapp.models import WorkOrder
class WorkOrderTable(tables.Table):
class Meta:
model = WorkOrder
fields = ("call_date", "ordernum", "building", "unit", "request_by", 'problem_desc')
attrs = {"class": "paleblue"}
#template
{% extends "cdpapp/base_no_side_panel.html" %}
{% load render_table from django_tables2 %}
{% load staticfiles %}
{% block title %}All Work Orders{% endblock %}
<head>
<link rel="stylesheet" href="{{ STATIC_URL }}django_tables2/themes/paleblue/css/screen.css" />
</head>
{% block content %}
{% render_table table %}
{% endblock content %}