django admin custom view in model properties
<p>I have such models:</p>

<pre><code>class Product(models.Model):
    ...
    id = models.IntegerField(unique=True)
    ...

class Question(models.Model):
    product = models.ForeignKey(Product, related_name='question', null=True)
    answer = models.ForeignKey(Answer, related_name='question', blank=True, null=True)
    user = models.ForeignKey(User, null=True)
    text = models.TextField(null=True)
    ...

class Answer(models.Model):
    user = models.ForeignKey(User, null=True)
    text = models.TextField(null=True)
    ...
</code></pre>

<p>All these models are registered in django admin.
How can I get a custom report table while editing one of a Questions (/admin/qa/question/1/change/):</p>

<pre><code>...
editable standart_fields from Question model
...
non-standart report(without editable fields):
all questions:                   related answers to them
User: Question(related to a product) - User: Answer to it
User: Question(if it exists)         - User: answer to it 
</code></pre>

<p>Is it possible in admin site?</p>

<p>You'll need to create a custom <strong>ModelAdmin</strong> for <strong>Questions</strong> and override the <strong>form</strong> property, as explained at <a href="https://docs.djangoproject.com/en/1.10/ref/contrib/admin/#django.contrib.admin.ModelAdmin.form" rel="nofollow">https://docs.djangoproject.com/en/1.10/ref/contrib/admin/#django.contrib.admin.ModelAdmin.form</a>.</p>

<p>In your case, you should get the dynamically created form using <strong>ModelAdmin.get_form()</strong> and add the report you want to it, using Django's form framework.</p>

python django django-models django-admin django-views