On May 13, 2008, at 01:00 , Mike Chambers wrote:
> > I am working on a simple comment app that is meant to be generic and > reusable. Everything is going well, but the one thing I am having a > problem with is how to handle comment submissions that dont validate. > > For a normal form post, I would just validate the Form in the view, > and > then render the template with the Form. The template would then access > the errors from the form class. > > However, since my comment app is standalone, it does not know which > template should be rendered, and which data should be passed to the > template. You could have the error-handling app override the template for the comment app. Consider something like this: def submit_comment(request): ... return render_to_response(['comments/template.html', 'comments/ default-template.html'], {form: the_form}) You would provide the "comments/default-template.html" template with the reusable comments app, and in your project, add a "comments/ template.html" template, possibly in its own application. This works because render_to_response (and render_to_string) tries to use the templates in the order you listed them; the first match gets rendered. For more examples of this, look at django.contrib.admin, where it's used to allow you to override the admin interface's templates on a per- app and per-model basis. Cheers, -- Alex --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---