Table for testing
This commit is contained in:
16
asuzr/tables.py
Normal file
16
asuzr/tables.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from django.utils.safestring import mark_safe
|
||||||
|
import django_tables2 as tables
|
||||||
|
from models import *
|
||||||
|
|
||||||
|
def editable(field_name):
|
||||||
|
return '{{% load inplace_edit %}}\n\n{{% inplace_edit "record.{field}" auto_height = 1 %}}'.format(field = field_name)
|
||||||
|
|
||||||
|
class TestTable(tables.Table):
|
||||||
|
name = tables.TemplateColumn(editable('name'),verbose_name = "Наименование")
|
||||||
|
prod_period = tables.TemplateColumn(editable('prod_period'),verbose_name = "Время производства")
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Product
|
||||||
|
attrs = {"class": "paleblue"}
|
||||||
@@ -10,6 +10,8 @@ from datetime import datetime, date, timedelta
|
|||||||
import calendar
|
import calendar
|
||||||
from django.db.models import Count, Sum
|
from django.db.models import Count, Sum
|
||||||
from asuzr.common import custom_date
|
from asuzr.common import custom_date
|
||||||
|
from tables import *
|
||||||
|
from django_tables2 import RequestConfig
|
||||||
|
|
||||||
def prod_list(request):
|
def prod_list(request):
|
||||||
product_list = Product.objects.all()
|
product_list = Product.objects.all()
|
||||||
@@ -127,7 +129,10 @@ def desreport(request):
|
|||||||
})
|
})
|
||||||
return HttpResponse(t.render(c))
|
return HttpResponse(t.render(c))
|
||||||
|
|
||||||
|
def table_test(request):
|
||||||
|
table = TestTable(Product.objects.all())
|
||||||
|
RequestConfig(request).configure(table)
|
||||||
|
return render(request, 'asuzr/tabletest.html', {'table': table, 'action': Product.objects.all()[0]})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,5 +13,6 @@ urlpatterns = patterns('',
|
|||||||
url(r'^orders/(?P<archive>\d+)/$', 'asuzr.views.orders'),
|
url(r'^orders/(?P<archive>\d+)/$', 'asuzr.views.orders'),
|
||||||
url(r'^desreport/$', 'asuzr.views.desreport'),
|
url(r'^desreport/$', 'asuzr.views.desreport'),
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
|
url(r'^table/', 'asuzr.views.table_test'),
|
||||||
url(r'^inplaceeditform/', include('inplaceeditform.urls')),
|
url(r'^inplaceeditform/', include('inplaceeditform.urls')),
|
||||||
)
|
)
|
||||||
|
|||||||
8
templates/asuzr/tabletest.html
Normal file
8
templates/asuzr/tabletest.html
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{% extends "asuzr/base.html" %}
|
||||||
|
{% load inplace_edit %}
|
||||||
|
{% load render_table from django_tables2 %}
|
||||||
|
|
||||||
|
{% block page %}
|
||||||
|
{% render_table table %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
Reference in New Issue
Block a user