djangosnippets.org: Latest snippets tagged with 'site'http://djangosnippets.org/tags/site/2008-11-17T14:35:58.925128-06:00Add site info to request context
2008-11-17T14:35:58.925128-06:00bthomashttp://djangosnippets.org/snippets/1197/<p>Sometimes you want to generate a <strong>really</strong> absolute URL, but the built-in url tag only generates a URL relative to the current domain. This context processor adds the extra information needed to the request context, so you can generate an absolute URL in a template like so:
</p>
<p><code>{{ protocol }}://{{ …</code></p>
Freely redistributableDefault to current/all sites in admin (updated!)
2008-10-12T04:43:14.116929-05:00dokterbobhttp://djangosnippets.org/snippets/1128/<p>This code sets the default sites for a sites ManyToMany property to <code>Site.objects.all()</code>, which makes sure you don't have to bother setting it for each item on a site.</p>
<p>This could easily be changed to <code>Site.objects.get_current()</code> to use the current site as default.</p>
Freely redistributable