Opened 15 years ago
Closed 12 years ago
#11549 closed New feature (wontfix)
contrib.comments should allow users to specify their own template on error
Reported by: | Teebes | Owned by: | Teebes |
---|---|---|---|
Component: | contrib.comments | Version: | dev |
Severity: | Normal | Keywords: | comments, error, preview |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | yes | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
Currently in contrib.comments, if there is an error on the form the user is taken to a page that is generated by the preview template. This means that you can't have the user stay on the exact same page they were on if they submitted it with a mistake.
This patch introduces a new parameter to post_comment in contrib.comments.views.comments, that is None by default but that can contain an overwrite template location and extra context variable.
To get this to work, a user would just need to overwrite the comments/post url in urls.py and make it point to a custom wrapper around post_comment. For example:
urls.py:
(r'^comments/post/$', 'thebes.quanda_comments.views.custom_post_comment'),
quanda_comments/views.py:
from django.contrib.comments.views.comments import post_comment from django.http import HttpResponseRedirect from thebes.quanda.models import Answer def custom_post_comment(request): answers = Answer.objects.all() error_page = { 'template': 'quanda/index.html', 'data': { 'answers': answers }, } response = post_comment(request, error_page=error_page) return response
The impact is minimal, with only one file changed and no reverse compatibility issues. I've inclued both code path and documentation patch.
Attachments (1)
Change History (9)
by , 15 years ago
Attachment: | comments_patch.diff added |
---|
comment:1 by , 15 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 15 years ago
I forgot to mention that this originated in the following stackoverflow thread:
http://stackoverflow.com/questions/1174140/django-comments-how-to-prevent-form-errors-from-redirecting-the-user-to-the-prev
comment:3 by , 15 years ago
Triage Stage: | Unreviewed → Accepted |
---|
Nothing wrong with the idea, but it should be implemented in a way that maintains parity with other configurable template views (like the generic views). This means passing in a template_name and extra_context arguments, rather than a dictionary.
comment:4 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:5 by , 14 years ago
Needs documentation: | set |
---|---|
Needs tests: | set |
Patch needs improvement: | set |
Patch needs improvement as per Russell's comment. Also needs tests and (better) doc to reflect the requested improvement.
comment:8 by , 12 years ago
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
django.contrib.comments
has been deprecated and is no longer supported, so I'm closing this ticket. We're encouraging users to transition to a custom solution, or to a hosted solution like Disqus.
The code itself has moved to https://github.com/django/django-contrib-comments; if you want to keep using it, you could move this bug over there.
Patch to contrib.comments (code & documentation) to allow error template selection