Question

Im trying to insert the registration-form template from django-registration in another html document. The original Registration template it's working perfectly fine and users are saved in the DB:

This is what happend when i try to insert the registration form in any other html document using {% extend registration/myRegistrationFormTemplate.html %}. Fields are not showed and the submit button don't work.

Also, this is what happend when i try to load myRegistrationFormTemplate.html using the Jquery method .load. Fields are showed but the submit button don't work.

The question is: Why this is happening? and what's the usual procedure to do this?

Was it helpful?

Solution

You might need to use include which allows you to render the included page with the current context. However, this totally depends how you design your templates structure and how they extends other templates. This answer might explain the difference: https://stackoverflow.com/a/2863753/2074398

OTHER TIPS

Thanks FallenAngel you were right, i was missing the view info. And thanks for telling me about "include" almalki, now all it's working right. In my project im using 2 forms in this view and a jquery modal window. To simplify my solution i'll only use one form. I hope this will be useful for someone.

SOLUTION: View of the template you'll include the form

def patrimonio_view(request, 
     template_name='home/patrimonio.html'):

#OTHER DB QUERYS
pat = patrimonio.objects.all()
ciu = ciudad.objects.all()

if request.method == 'POST':
    if "Registrar_usuario" in request.POST:
        #USER REGISTRATION FORM RELATIVE
        return register_usuario()

    if "Registrar_comerciante" in request.POST:
        #MERCHANT REGISTRATION FORM RELATIVE
        return register_comerciante()

#RENDER
return render_to_response(template_name,{
   'patrimonio':pat, 
   'ciudad':ciu,
}, context_instance=RequestContext(request))

urls.py

url(r'^patrimonio/$','patrimonio_view',
{'backend_registro_usuario': 'Hesperides.apps.accounts.regbackend_usuario.DefaultBackend','form_class_usuario':RegistrationForm_usuario}, name='vista_patrimonio'),

in the template you will include the form:

{% include "registration/registration_form_usuario.html" %}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top