I couldn't find a description field in the creation of your ContactForm.
Maybe it's an oversight from me. However, if it isn't, I'm not expecting to
see a {{card.description}} in your cards.html page.On 12:30PM, Fri, Jun 7, 2019 Delcy John <[email protected]> wrote: > i think the error is in form.py,you must put indentation in class > > On Fri, Jun 7, 2019 at 9:37 AM Joe Reitman <[email protected]> wrote: > >> Interesting problem. It won't display because the form is inside a >> for-loop. Django Template language looks at variables inside a for-loop >> differently. Basically it looks for a collection. Since {{ form }} is not a >> collection, it just ignores it. >> >> I'm not sure how you can create multiple forms like that. But I would be >> interested in knowing. >> >> >> On Thursday, June 6, 2019 at 6:14:57 PM UTC-5, Majid Rafiee wrote: >>> >>> I've created a form in Django: >>> >>> #forms.py >>> from django import forms >>> >>> >>> class ContactForm(forms.Form): >>> name = forms.CharField() >>> number = forms.FloatField() >>> eail_user = forms.EmailField() >>> >>> >>> and imported in in views.py >>> >>> #views.pyfrom django.shortcuts import renderfrom .models import Cardsfrom >>> cards.forms import ContactForm >>> >>> def index(request): >>> cards = Cards.objects.all() >>> return render(request,'card.html', {'cards':cards}) >>> >>> def contact(request): >>> form = ContactForm() >>> return render(request,'card.html', {'form': form}) >>> >>> This is my base.html >>> >>> #base.html >>> {% load staticfiles %} >>> <!DOCTYPE html> >>> <html lang="en"> >>> <head> >>> <link >>> href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" >>> rel="stylesheet" id="bootstrap-css"> >>> <script >>> src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script> >>> <script >>> src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> >>> <link href="{% static 'css/stylesheet.css' %}" rel="stylesheet" >>> type="text/css"> >>> <!------ Include the above in your HEAD tag ----------> >>> <meta charset="UTF-8"> >>> <title>Title</title> >>> </head> >>> <body> >>> <section id="team" class="pb-5"> >>> <div class="container"> >>> <h5 class="section-title h1">OUR TEAM</h5> >>> <div class="row"> >>> {% block content %} >>> {% endblock %} >>> </div> >>> </div> >>> </section> >>> </body> >>> </html> >>> >>> >>> And here is the card.html that is extended from base.html >>> >>> #card.html >>> {% extends 'base.html' %} >>> >>> {% block content %} >>> <!-- Team --> >>> {% for card in cards %} >>> <!-- Team member --> >>> <div class="col-xs-12 col-sm-6 col-md-4"> >>> <div class="image-flip" >>> ontouchstart="this.classList.toggle('hover');"> >>> <div class="mainflip"> >>> <div class="frontside"> >>> <div class="card"> >>> <div class="card-body text-center"> >>> <p><img class=" img-fluid" >>> >>> src="https://sunlimetech.com/portfolio/boot4menu/assets/imgs/team/img_01.png" >>> alt="card image"></p> >>> <h4 class="card-title">{{ card.name }}</h4> >>> <p class="card-text">{{ card.description >>> }}</p> >>> <a href="#" class="btn btn-primary >>> btn-sm"><i class="fa fa-plus"></i></a> >>> </div> >>> </div> >>> </div> >>> <div class="backside"> >>> <div class="card"> >>> <div class="card-body text-center mt-4"> >>> <h4 class="card-title">{{ card.name }}</h4> >>> <!--<p class="card-text"> {{ >>> card.back_description }}--> >>> <form action="/your-name/" method="post"> >>> {% csrf_token %} >>> {{ form }} >>> <input type="submit" value="Submit"> >>> </form> >>> <!--</p> --> >>> <ul class="list-inline"> >>> <li class="list-inline-item"> >>> <a class="social-icon >>> text-xs-center" target="_blank" href="#"> >>> <i class="fa fa-facebook"></i> >>> </a> >>> </li> >>> <li class="list-inline-item"> >>> <a class="social-icon >>> text-xs-center" target="_blank" href="#"> >>> <i class="fa fa-twitter"></i> >>> </a> >>> </li> >>> <li class="list-inline-item"> >>> <a class="social-icon >>> text-xs-center" target="_blank" href="#"> >>> <i class="fa fa-skype"></i> >>> </a> >>> </li> >>> <li class="list-inline-item"> >>> <a class="social-icon >>> text-xs-center" target="_blank" href="#"> >>> <i class="fa fa-google"></i> >>> </a> >>> </li> >>> </ul> >>> </div> >>> </div> >>> </div> >>> </div> >>> </div> >>> </div> >>> <!-- ./Team member --> >>> {% endfor %} >>> >>> {% endblock %} >>> >>> >>> As you may notice, I've called form by {{ form }} inside <form> tag in >>> card.html but the issue is that it just shows a Submit botton and ignores >>> {{ form }}. Any idea how to solve the issue? >>> I also bring urls.py in cards app and main urls: >>> #urls.py in cards >>> from django.urls import path >>> from . import views >>> >>> >>> urlpatterns = [ >>> path('', views.index), >>> path('form/', views.contact), >>> ] >>> >>> >>> #urls.py in main directory >>> >>> from django.contrib import admin >>> from django.urls import path, include >>> >>> >>> urlpatterns = [ >>> path('admin/', admin.site.urls), >>> path('calculator_one_input/', include('calculator_one_input.urls')), >>> path('cards/', include('cards.urls')), >>> path('cards/form/', include('cards.urls')), >>> ] >>> >>> >>> I looked for a solution for three days and still I have no idea how to >>> solve this issue. I will be so appreciated if someone give me a clear clue >>> how to solve. Thanks >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at https://groups.google.com/group/django-users. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/9ea7647f-1fb8-429c-8988-0d07459678ff%40googlegroups.com >> <https://groups.google.com/d/msgid/django-users/9ea7647f-1fb8-429c-8988-0d07459678ff%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAPmWs92Acv-i8iaX-r0GU9LCH31YPn8qr%3DyNEQCXOO3ZWMD-dA%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAPmWs92Acv-i8iaX-r0GU9LCH31YPn8qr%3DyNEQCXOO3ZWMD-dA%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAG%3D1guzyCYJ_-fP_fgMfyF%3DjCpgdNMMN-at-QULsYW0YDBZpPw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

