Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It looks like the domain is a subdomain of your own website so what does it matter that you can't reverse that part? Using <code>reverse</code> it doesn't use full domain paths, it gives you the path from the root of the project, so you can simply do something like:</p> <pre><code>new_post_uri = 'http://%s.domain:9292%s' % (site.domain, reverse('manage_new_post')) </code></pre> <p>This way you're still using reverse so you're not hardcoding the urls (and making babies cry) and you're not realy having an issue as far as I can see.</p> <p>Finally, if you do not wish to hardcode your own domain in the code, uses Django's <a href="http://docs.djangoproject.com/en/1.1/ref/contrib/sites/#ref-contrib-sites" rel="nofollow noreferrer">Sites</a> model to get the current site, make sure to modify it from the default example.com to your own domain, so finally your code can be:</p> <pre><code>current_site = Site.objects.get_current() # See the docs for other options return redirect('http://%s.%s%s' % (site.domain, current_site, reverse('manage_new_post'))) </code></pre> <p>If you need to get the domain without using the Sites object, your best bet may be <a href="http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.get_host" rel="nofollow noreferrer">request.get_host()</a>, which will get the full domain plus port, but not the protocol.</p> <p>Hopefully that explains things for you. You can format things a bit better, but that's the gist of it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload