views:

134

answers:

0

Hi everybody, I'm new to Django development and I'm a little bit confused with the templates and the newforms functionalities. I need to perform a dynamic include or extends on Django, and I'm not sure if it's possible.

I have my index.html template page, and one of the available funcionalities on it (among others) is the login form. The fields on this login form are generated using newforms (using form.as_p). This form is contained on the page signin.html

To execute this, you need to call the view /signup/singin/ on the url. Doing so the User/Pass fields are correctly displayed.

But now I need to include this signin.html page on my index.html page, and I cannot do it using the {% include %} or the {% extends %} because these are static includes, therefore the view is not executed and the User/Pass fields are not displayed.

index.html:

<html>
  <body>
    {% include "signin.html" %}
  </body>
</html>

signin.html:

<table class="moduletable" cellpadding="0" cellspacing="0">
  <tr>
    <td>
      <form action="{% url signup.views.signin %}" method="post">
        {{ form.as_p }}
        <input name="Submit" class="button" value="Login" type="submit">
      </form>
    </td>
  </tr>
</table>

signup.forms:

class SignInForm(forms.Form):
    userid = forms.CharField(label=_(u"User ID"), min_length=4)
    password = forms.CharField(label=_(u"Password"), widget=forms.PasswordInput(), min_length=6)

What I need is something like

{% include "/signup/singin/" %}

Any clue? I'm I missing something important?

Thanks!

related questions