2

I am developing a website using django. I added a link to an element but yet to create view for it.

But django doesn't let me test my changes until I finish writing the view. It issues NoReverseMatch error. I tried commenting out that part of html using these <!-- xxxx --> but still django issues the same error.

How can I comment out the html so djano won't process it.

samsri
  • 1,104
  • 14
  • 25

2 Answers2

5

Surround the parts of the template with the template comment tag, and django will ignore it:

{# <a href="{% url('does-not-exist') %}">foo</a> #}

In most text editors that are aware of django templates, you can hit CTRL+/ to comment out the templates.

Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284
0

You can use {# ... #} or {% comment 'Blah-blah-blah' %}...{% endcomment %} tag. Also, you can create dummy view and use it in urls instead of not yet created views:

views.py

def dummy(request, *args, **kwargs):
    return HttpResponse('Dummy View')

urls.py

urlpatterns = [
    ...
    url(r'^index/$', views.dummy, name='index'),
    url(r'^page/(\d+)/$', views.dummy, name='page'),
    ...
]
f43d65
  • 314
  • 2
  • 7