On Tue, 2006-10-10 at 05:28 -0700, timc3 wrote: > So I am building my App and I have got the comments system working as I > want for the first round but I would like to utilise ajax to be able to > post and update in the page, rather than new pages all the time. > > I have read though some excellent posts on ajax and django, and > understand what is required, but it looks like the views in the > standard comments system would have to changed to support sending back > text/javascript instead of what they are doing at the moment. > > Is this really the case? Can I specify a custom view without having > to edit the django framework, or am I going to have to do this?
You are going to have to write your own view, for precisely the reasons you mentioned. However, you don't need to change the Django source. Since your URL configuration file is processed first, you can override any of the specific URLs that might otherwise be dispatched to the comments' views and send them to your own view functions instead. So, for example, you might currently have a line like (r'comments/', include('django.contrib.comments.urls')) in your urls.py. That list of url patterns is processed from front to back and the first match is used, so you could divert the posting view by including a line immediately prior to the above: (r'comments/post/$', 'myapp.views.json.comment_post'), (r'comments/', include('django.contrib.comments.urls')), and so forth. Overriding the standard URL paths like this is a good way to customise certain paths. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---