Note that there are some explanatory texts on larger screens.

plurals
  1. POCustomising the Django comment app
    primarykey
    data
    text
    <p>I'm having problems with customising the django comments framework. I need to add a 'company' field. I've followed the documentation and not really getting anywhere. It's not far from working because when i add COMMENTS_APP = 'comments_app' to my settings.py the 'comments' app dissapears from admin interface. When i try and write a comment it comes up with the company field where it asks for your email, url etc.</p> <p>I'd like to be able to view all the comments in the admin panel along with the company field i've added.</p> <p>Do i need to create a admin.py or have i just got something missing?</p> <p>Here is my code for my customised comments app:</p> <p>//MODELS</p> <pre><code> from django.db import models from django.contrib.comments.models import Comment class CommentWithAddedFields(Comment): company = models.CharField(max_length=300) </code></pre> <p>//FORMS.py </p> <pre><code>from django import forms from django.contrib.comments.forms import CommentForm from comments_app.models import CommentWithAddedFields class CommentFormWithAddedFields(CommentForm): company = forms.CharField(max_length=300) def get_comment_model(self): return CommentWithAddedFields def get_comment_create_data(self): data = super(CommentFormWithAddedFields, self).get_comment_create_data() data['company'] = self.cleaned_data['company'] return data </code></pre> <p>//__init.py</p> <pre><code>from comments_app.models import CommentWithAddedFields from comments_app.forms import CommentFormWithAddedFields def get_model(): return CommentWithAddedFields def get_form(): return CommentFormWithAddedFields </code></pre> <p>I have added the app in the my settings.py file and added COMMENTS_APP = 'comments_app' as i mentioned above.</p> <p>Am I missed something?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload