How to create a table from a DetailView using django_tables2?

There are the following models:

class Group(models.Model):
 group_name = models.CharField(max_length=250, verbose_name='object Name', help_text='Name of object')
 date_create = models.DateTimeField(verbose_name='creation date', auto_now_add=True)
 date_updated = models.DateTimeField(verbose_name='date edit', auto_now=True)

class Message(models.Model):
 group = models.ForeignKey(Group, verbose_name='Object', null=True, blank=True, related_name='messages')
 message_text = models.TextField(verbose_name='Comment', help_text='Comment')

While printing some information:

class DetailView(generic.DetailView):
 model = Group

 def get_object(self):
 object = super(DetailView, self).get_object()
 return object

 def get_context_data(self, **kwargs):
 context = super(DetailView, self).get_context_data(**kwargs)
 context['message_list'] = Message.objects.filter(group=self.get_object())
 return context

url(r'^grp/(?P<pk>[0-9]+)/$', views.DetailView.as_view(), name='detail'),


{% extends "ruik/base.html" %}
{% block head_title %} Details | {{ block.super }} {% endblock %}
{% block content %}

<h1>{{ group.group_name }}</h1>
 </p><li>creation Time: {{ group.date_create }}</li>
 the <li>modified Time: {{ group.date_updated }}</li>

{% for message in message_list %}
 </p><li><a href="{% url 'mssgs:detail' %}">{{ message.message_text }}</a></li>
{% endfor %}

{% endblock %}</pk>

I need instead
{% for message in message_list %}
 the <li><a href="{% url 'mssgs:detail' %}">{{ message.message_text }}</a></li>
{% endfor %}

table of withdraw using django_tables2.

Separately Message through the ListView it worked. Think now how this same table to insert...
July 2nd 19 at 17:50
0 answer

Find more questions by tags Django