<p>Does Django have any template tags to generate common HTML markup? For example, I know that I can get a url using</p>

<pre><code>{% url mapper.views.foo %}
</code></pre>

<p>But that only gives me the URL and not the HTML code to create the link. Does Django have anything similar to Rails' link_to helper? I found <a href="http://code.google.com/p/django-helpers/" rel="noreferrer">django-helpers</a> but since this is a common thing I thought Django would have something built-in.</p>

[{'answer_id': 61457, 'author': 'John Boker', 'author_id': 2847, 'author_profile': 'https://Stackoverflow.com/users/2847', 'pm_score': 2, 'selected': False, 'text': '<p>it doesnt look like they\'re built in but here\'s a couple snippets.  it looks like it\'d be pretty easy to create these helpers:</p>\n\n<p><a href="http://www.djangosnippets.org/snippets/441/" rel="nofollow noreferrer">http://www.djangosnippets.org/snippets/441/</a></p>\n'}, {'answer_id': 67590, 'author': 'saturdayplace', 'author_id': 3912, 'author_profile': 'https://Stackoverflow.com/users/3912', 'pm_score': 6, 'selected': True, 'text': '<p>No it doesn\'t.</p>\n\n<p><a href="http://www.b-list.org/" rel="noreferrer">James Bennett</a> answered a <a href="http://www.b-list.org/weblog/2006/jul/02/django-and-ajax/" rel="noreferrer">similar question</a> a while back, regarding Rails\' built-in JavaScript helpers.</p>\n\n<p>It\'s <em>really</em> unlikely that Django will ever have \'helper\' functionality built-in.  The reason, if I understand correctly, has to do with Django\'s core philosophy of keeping things <a href="http://docs.djangoproject.com/en/dev/misc/design-philosophies/#id1" rel="noreferrer">loosely coupled</a>.  Having that kind of helper functionality built-in leads to coupling Django with a specific JavaScript library or (in your case) html document type.  </p>\n\n<p>EG. What happens if/when HTML 5 is finally implemented and Django is generating HTML 4 or XHTML markup?</p>\n\n<p>Having said that, Django\'s template framework is really flexible, and it wouldn\'t be terribly difficult to <a href="http://docs.djangoproject.com/en/dev/howto/custom-template-tags/" rel="noreferrer">write your own tags/filters</a> that did what you wanted.  I\'m mostly a designer myself, and I\'ve been able to put together a couple custom tags that worked like a charm.</p>\n'}, {'answer_id': 67808, 'author': 'zuber', 'author_id': 9812, 'author_profile': 'https://Stackoverflow.com/users/9812', 'pm_score': 1, 'selected': False, 'text': '<p>Here is a <a href="http://docs.djangoproject.com/en/dev/ref/templates/builtins/" rel="nofollow noreferrer">list of all template tags and filters built into Django</a>. Django core doesn\'t have as much HTML helpers as Rails, because Django contributors assumed that web developer knows HTML very well. As stated by saturdaypalace, it\'s very unlikely for AJAX helpers to be added to Django, because it would lead to coupling Django with a specific JavaScript library.</p>\n\n<p>It\'s very easy to <a href="http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-template-tags" rel="nofollow noreferrer">write your own template tags</a> in Django (often you need just to define one function, similiar to Rails). You could reimplement most of Rails helpers in Django during a day or two.</p>\n'}, {'answer_id': 71598, 'author': 'Ali', 'author_id': 11895, 'author_profile': 'https://Stackoverflow.com/users/11895', 'pm_score': -1, 'selected': False, 'text': '<p>This won\'t answer directly to the question, but why not using <code>&lt;a href="{% url mapper.views.foo %}"&gt;foo&lt;/a&gt;</code> in template then?</p>\n'}, {'answer_id': 82175, 'author': 'zgoda', 'author_id': 12138, 'author_profile': 'https://Stackoverflow.com/users/12138', 'pm_score': 0, 'selected': False, 'text': "<p>I bet if there would be any consent of what is <em>common html</em>, there would be helpers module too, just for completeness (or because others have it). ;)</p>\n\n<p>Other than that, Django template system is made mostly for HTML people, who already know how to write <code>p</code>, <code>img</code> and <code>a</code> tags and do not need any <em>helpers</em> for that. On the other side there are Python developers, who write code and do not care if the variable they put in context is enclosed by <code>div</code> or by <code>span</code> (perfect example of <em>separation of concerns</em> paradigm). If you need to have these two worlds to be joined, you have do to it by yourself (or look for other's code).</p>\n"}, {'answer_id': 1449028, 'author': 'Whatcould', 'author_id': 175689, 'author_profile': 'https://Stackoverflow.com/users/175689', 'pm_score': 5, 'selected': False, 'text': '<p>The purpose of helpers is not, as others here imply, to help developers who don\'t know how to write HTML. The purpose is to encapsulate common functionality -- so you don\'t need to write the same thing a thousand times -- and to provide a single place to edit common HTML used throughout your app.</p>\n\n<p>It\'s the same reason templates and SSI are useful -- not because people don\'t know how to write the HTML in their headers and footers, but sometimes you want to write it just once.</p>\n\n<blockquote>\n  <p>EG. What happens if/when HTML 5 is\n  finally implemented and Django is\n  generating HTML 4 or XHTML markup?</p>\n</blockquote>\n\n<p>Same thing that happens when HTML 5 is implemented and all your templates are written in repetitive HTML, except a lot easier.</p>\n\n<p>The other posts have already answered the question, linking to the docs on <a href="http://docs.djangoproject.com/en/dev/howto/custom-template-tags/" rel="noreferrer">custom template tags</a>; you can use tags and filters to build your own, but no, there aren\'t any built in.</p>\n'}]
['https://Stackoverflow.com/questions/61451', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/796/']