django-tables2

With django-tables2 how do I display a model @property?

我只是一个虾纸丫 提交于 2020-01-05 10:08:14
问题 I have a @property in my model which is basically a string of several values in the model combined. @property def mfg_link(self): return ''.join('http://mfg.com/model/' + str(self.model_numer)) I can add this mfg_link to the list_display on the admin model and it works fine, but its not showing up in the generated table when I pass the queryset to the table, the other fields show up fine. This seems like something obvious, but unfortunately the couple of hours of searching didn't help. Thanks

Django tables 2: error django.template.context_processors.request

非 Y 不嫁゛ 提交于 2020-01-05 06:56:07
问题 I installed the module tables 2 and i have the next problem: Exception Value: Tag {% querystring %} requires django.template.context_processors.request to be in the template configuration in settings.TEMPLATES[]OPTIONS.context_processors) in order for the included template tags to function correctly. My code is: Settings.py TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR + '/llamadas/plantillas')], 'APP_DIRS': True, 'OPTIONS': {

how do i create a table from a dict using django-tables2

孤街浪徒 提交于 2020-01-04 12:46:16
问题 I have a list of dict that look like this: [set([u'meal', '0:08:35.882945']), set([0, u'personal']), set([0, u'sleep']), set([0, u'transport']), set([0, u'work'])] That I made from : [u'meal',u'personal', u'sleep', u'transport', u'work'] ['0:08:35.882945', 0, 0, 0, 0] With this command: nob = [{m,n} for m,n in zip(cats,tot3)] How can I turn this into a django-tables2 table? I tried this : # tables.py class Small_table (tables.Table): category = tables.Column(verbose_name="category") class

formatting table cell content in django-tables2

谁说我不能喝 提交于 2020-01-01 20:01:30
问题 Love django-tables... but something that I'm sure is trivial to solve is giving me fits. When the value I pass for a given row/column is like: some<br/>random<br/>words<br/>returned I want the browser to parse and render the content in that cell... to look like this: some random words returned not escape the content I'm passing and display it like this: some<br/>random<br/>words<br/>returned Surely there's some flag or option that I've missed? 回答1: Use mark_safe as follows: import django

formatting table cell content in django-tables2

流过昼夜 提交于 2020-01-01 20:01:15
问题 Love django-tables... but something that I'm sure is trivial to solve is giving me fits. When the value I pass for a given row/column is like: some<br/>random<br/>words<br/>returned I want the browser to parse and render the content in that cell... to look like this: some random words returned not escape the content I'm passing and display it like this: some<br/>random<br/>words<br/>returned Surely there's some flag or option that I've missed? 回答1: Use mark_safe as follows: import django

badly formed hexadecimal UUID error string for a UUID primary key

允我心安 提交于 2019-12-31 05:37:06
问题 I'm trying to get my table to load, but am getting this error, most likely because my primary key is a uuid. Here is my url paths. path('results/', views.results, name='results'), path('results/<uuid:pk>/', views.genre_book, name='books_genre_table'), Here is my views.py If there is one observation, we load the price table. If not, then we load a table with service descriptions. The user can then pick the service they are most interested and click through to the price table for that service.

Is it possible to custom django-tables2 template for a specific page in this case?

主宰稳场 提交于 2019-12-31 04:50:26
问题 I'm using django-tables2 to render my data in tables in the template.. everything is rendered fine with pagination.. The Designer of our company wants to change the Display of data into blocks instead of simple table. the following picture may explain more. I Want to ask if I can use Django tables2 in this case ..since I don't want to loose the pagination Is it possible to custom the django_tables2/table.html file to only fit this case (because I'm using django-tables2 in many other pages in

Non-queryset data ordering in django-tables2

只谈情不闲聊 提交于 2019-12-30 17:21:08
问题 The docs say: Where the table is backed by a model, the database will handle the ordering. Where this is not the case, the Python cmp function is used and the following mechanism is used as a fallback when comparing across different types: ... But is this possible in a table that is backed by a model, on a custom column? e.g. class MyModel(models.Model): x = models.IntegerField() y = models.IntegerField() def z(self): return x+y class MyTable(tables.Table): z = tables.Column() class Meta:

Putting a click event for a dialogue box with Django Tables2

随声附和 提交于 2019-12-24 07:50:41
问题 I am trying to make a click event with Django Tables2 so that whenever someone clicks on a delete link in a row it will create a dialogue box for confirmation before deleting the row. Here is my code: models.py class Schedules(models.Model): course_name = models.CharField(max_length=128, choices=COURSE_NAME_CHOICES, default='a-plus') location = models.CharField(max_length=128, choices=LOCATION_CHOICES, default='south_plainfield') room = models.CharField(max_length=128, choices=ROOM_CHOICES,

Accessing related models with django-tables2

时光怂恿深爱的人放手 提交于 2019-12-23 12:28:18
问题 Can anyone provide a clear example of how to create a table object using django-tables2 that selects and presents data from multiple related models (ie a relational join)? The documentation implies this is possible, but does not say how. In normal django the select_related() function works nicely, but I cannot work out how to implement this in django-tables2. I note there are other unanswered questions on similar topics. 回答1: First, select_related() is not required to access related data, it