1

Possible Duplicate:
Can I access constants in settings.py from templates in Django?

I am trying to create a template , which contains some hyperlinks and redirect url. I have seperate production and staging server . I have already tried request.get_full_path on template but it is rendering query string rather than domain name. Any idea?

in settings.py i did following

TEMPLATE_CONTEXT_PROCESSORS = (
     "django.core.context_processors.request",
     "django.contrib.auth.context_processors.auth"

     )

My template is as follows

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="business" value="sumit_1349250468_per@ersumit.com">
    <input type="hidden" name="item_name" value="registration charge {{ request.session.username }}">
    <input type="hidden" name="item_number" value="{{ request.session.userid }}">
    <input type="hidden" name="amount" value="9.00">
    <input type="hidden" name="no_shipping" value="0">
    <input type="hidden" name="no_note" value="1">
    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="lc" value="AU">
    <input type="hidden" name="bn" value="PP-BuyNowBF">
    <input type="image" src="https://www.paypal.com/en_AU/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
    <img alt="" border="0" src="https://www.paypal.com/en_AU/i/scr/pixel.gif" width="1" height="1">
    <input type="hidden" name="return" value="{{ request.get_full_path}}accounts/success">
    <input type="hidden" name="cancel_return" value="{{ request.get_full_path}}/accounts/sorry">

</form>

I don't want to create any custom views

Community
  • 1
  • 1
hangman
  • 865
  • 5
  • 20
  • 31
  • Refer this http://stackoverflow.com/questions/433162/can-i-access-constants-in-settings-py-from-templates-in-django – Rohan Oct 07 '12 at 06:46
  • @Rohan : I dont want to create custom views.. i am using django registration , so i want to use constant from settings.py on registation_complete.html – hangman Oct 07 '12 at 06:55
  • Please read up the mentioned question and answers. There are multiple answers with different approaches. – Rohan Oct 07 '12 at 06:59
  • 1
    With or without "custom views", this is never going to work: PROJECT_ROOT is a file path, which has no place in a URL. – Daniel Roseman Oct 07 '12 at 07:17
  • You could follow the link posted by Rohan to make `PROJECT_ROOT` accessible in the template. But be warned that its unsafe to show the variable to public and even rely it in furthering logic. – okm Oct 07 '12 at 07:41
  • http://stackoverflow.com/questions/1451138/how-can-i-get-the-domain-name-of-my-site-within-a-django-template i found it .. sorry all to waste your time .. should i delete this question? – hangman Oct 07 '12 at 08:04

0 Answers0