python - form not being loaded into template -
i trying implement form in django not appearing. checked inspector on browser , not see @ meaning not being loaded.
if there other information needed. let me know.
project structure:
/beerad urls.py /index views.py /templates /index index.html /templates /home home.html /navbar navbar.html /userapp forms.py views.py urls.py
userapp/forms.py:
class registrationfrom(forms.form): username = forms.charfield(max_length=50, widget=forms.textinput(attrs={"id": "signup-username", "name": "username", "placeholder": "username"})) first_name = forms.charfield(max_length=50, widget=forms.textinput(attrs={"id": "signup-firstname", "name": "firstname", "placeholder": "first name"})) last_name = forms.charfield(max_length=50, widget=forms.textinput(attrs={"id": "signup-lastname", "name": "lastname", "placeholder": "last name"})) email = forms.emailfield(max_length=50, widget=forms.emailinput(attrs={"id": "signup-email", "name": "email", "placeholder": "email"})) password = forms.charfield(max_length=32, widget=forms.passwordinput(attrs={"id": "signup-password", "name": "password", "placeholder": "password"})) confirm_password = forms.charfield(max_length=32, widget=forms.passwordinput(attrs={"id": "signup-confirm-password", "name": "confirm-password", "placeholder": "confirm password"}))
index/templates/index/index.html:
{% extends "home/home.html" %} {% block content %} {% endblock %}
index/views.py
def load_index(request): if request.method == "get": return render(request, "index/index.html")
templates/home/home.html
<body class="container"> {#{% block navbar %}{% endblock %}#} {% include "navbar/navbar.html" %} {% block content %}{% endblock %} {% include "footer/footer.html" %} {#{% block footer %}{% endblock %}#} </body>
i tried using {% blocks %}
navbar
not appear anymore. appears when use include
<body class="container"> {% include "navbar/navbar.html" %} {% block content %}{% endblock %} {% include "footer/footer.html" %} </body>
beerad/urls.py:
urlpatterns = patterns('', url(r'^admin/', include(admin.site.urls)), url(r'', include("index.urls")), url(r'auth/', include("userapp.urls")) )
userapp/urls.py
urlpatterns = patterns('', url(r'signup/$', register), url(r'activation/$', activation) )
userapp/views.py:
def register(request): if request.method == "post": form = registrationfrom(request.post) if form.is_valid(): return render(request, "success.html", {"payload": request.post}) else: return render(request, "error/404.html") else: form = registrationfrom() return render(request, "navbar/navbar.html", {"form": form})
beerad/templates/navbar/navbar.html:
<div role="tabpanel" class="tab-pane fade in" id="signup-pane"> <form class="signup-form" method="post" action="/auth/signup/" id="create-account"> {% csrf_token %} {{ form }} <button type="submit" class="btn btn-xl" id="create-acc-btn" name="signup-submit">create account</button> </form> </div>
your form entirely within navbar block, you've commented out in home template. nothing in block appear.
Comments
Post a Comment