How can I do ImageField and FileField in crispy forms On Thu, 20 Feb, 2020, 12:53 AM , <dhruvashah1221...@gmail.com> wrote:
> > > Yaa did that still facing issue > > > > *From: *onlinejudge95 <onlinejudg...@gmail.com> > *Sent: *Thursday, February 20, 2020 12:32 AM > *To: *django-users@googlegroups.com > *Subject: *Re: Re: I am filling up the form but my filled out items are > not rendering into database and also the session is not working > > > > The template file > > > > > > <*form **method**="post" **novalidate*> > > No action attribute defined here. Where do you expect the data to be sent? > > > {% csrf_token %} > > <*div **class**="form-group col-md-4 mb-0"*> > {{ form.name|as_crispy_field }} > </*div*> > <*div **class**="form-group col-md-4 mb-0"*> > {{ form.email|as_crispy_field }} > </*div*> > <*div **class**="form-group col-md-4 mb-0"*> > {{ form.link_sent|as_crispy_field }} > </*div*> > <*button **type**="submit" **class**="btn btn-primary"*>Start</*button*> > <*button **type**="submit" **class**="btn btn-primary"*>Save</*button*> > > </*form*> > {% endblock %} > > > > > > *From: *Farai M <faraimutamb...@gmail.com> > *Sent: *Wednesday, February 19, 2020 11:19 PM > *To: *django-users@googlegroups.com > *Subject: *Re: I am filling up the form but my filled out items are not > rendering into database and also the session is not working > > > > The session must be activated in the settings file check that it should > work smoothly. > > On the insert can u share the template file mostly .It is to do with post > requests not reaching back end. You can try to print the post request > before your save to model to see if all inputs are coming through.If it's > not that try get create to see if it's an problem with duplicates. > > > > > > > > > > > > > > *views.py from *django.views.generic *import *FormView, TemplateView > *from *django.shortcuts *import *render,redirect > *from *.models *import > *modelstep1,modelstep2,modelstep3,modelstep4,modelstep5,modelstep6,modelstep7,modelstep8,modelstep9,modelstep10 > *from *.forms *import > *FormStep1,FormStep2,FormStep3,FormStep4,FormStep5,FormStep6,FormStep7,FormStep8,FormStep9,FormStep10 > > *def *FormStep1View(request): > forms = FormStep1() > *return *render(request, *'form_1.html'*, context={*'form'*: forms}) > > > *def *addForm1(request): > form = FormStep1(request.POST) > *if *form.is_valid(): > u=modelstep1() > u.name = form.cleaned_data[*'name'*] > u.email = form.cleaned_data[*'email'*] > u.link_sent = form.cleaned_data[*'link_sent'*] > u.title = request.POST.get(*'name'*) > u.content = request.POST.get(*'email'*) > u.content = request.POST.get(*'link_sent'*) > u.save() > request.session[*'name'*] = u.name > request.session[*'email'*] = u.email > request.session[*'link_sent'*] =u.link_sent > *return *redirect(*'/form/2/'*,context={*'form'*: form}) > > > > *def *FormStep2View(request): > forms = FormStep2() > *return *render(request, *'form_2.html'*, context={*'form'*: forms}) > *def *addForm2(request): > form = FormStep2(request.POST) > *if *form.is_valid(): > v=modelstep2() > v.country=form.cleaned_data[*'country'*] > v.city=form.cleaned_data[*'city'*] > v.year_of_birth=form.cleaned_data[*'year_of_birth'*] > v.current_grade=form.cleaned_data[*'current_grade'*] > v.university=form.cleaned_data[*' university'*] > v.school=form.cleaned_data[*'school'*] > v.native_language=form.cleaned_data[*'native_language'*] > v.phone_number = form.cleaned_data[*'phone_number'*] > v.email_business=form.cleaned_data[*'email_business'*] > v.social_media=form.cleaned_data[*'social_media'*] > > request.session[*'country'*] = v.country > request.session[*'city'*] = v.city > request.session[*'year_of_birth'*] = v.year_of_birth > request.session[*'current_grade'*] = v.current_grade > request.session[*'university'*] = v.university > request.session[*'school'*] = v.school > request.session[*'native_language'*] = v.native_language > request.session[*'phone_number'*] = v.phone_number > request.session[*'email_business'*] = v.email_business > request.session[*'social_media'*]= v.social_media > *return *redirect(request, *'/form/3/'*, > context={*'form'*:form}) > > > *def *FormStep3View(request): > forms = FormStep3() > *return *render(request, *'form_3.html'*, context={*'form'*: forms}) > *def *addForm3(request): > form = FormStep3(request.POST) > *if *form.is_valid(): > x=modelstep3() > x.internship_idea = form.cleaned_data[*'internship_idea'*] > x.startup_business = form.cleaned_data[*'startup_business'*] > x.goals = form.cleaned_data[*'goals'*] > x.established_year = form.cleaned_data[*'established_year'*] > x.number_of_employees = form.cleaned_data[*'number_of_employees'*] > x.months = form.cleaned_data[*'months'*] > x.website = form.cleaned_data[*'website'*] > x.cell_number_business = > form.cleaned_data[*'cell_number_business'*] > x.co_founder_details = form.cleaned_data[*'co_founder_details'*] > x.social_media_business = > form.cleaned_data[*'social_media_business'*] > x.save() > request.session[*'internship_idea'*] = x.internship_idea > request.session[*'startup_business'*] = x.startup_business > request.session[*'goals'*] = x.goals > request.session[*'established_year'*] = x.established_year > request.session[*'number_of_employees'*] = x.number_of_employees > request.session[*'months'*] = x.months > request.session[*'website'*] = x.website > request.session[*'cell_number_business'*] = x.cell_number_business > request.session[*'co_founder_details'*]= x.co_founder_details > request.session[*'social_media_business'*] = > x.social_media_business > *return *redirect(request,*'/form/4/'*,context={*'form'*:form}) > > *def *FormStep4View(request): > forms = FormStep4() > *return *render(request, *'form_4.html'*, context={*'form'*: forms}) > *def *addForm4(request): > form = FormStep4(request.POST) > *if *form.is_valid(): > y=modelstep4() > y.funding = form.cleaned_data[*'funding'*] > y.domain = form.cleaned_data[*' domain'*] > y.stage_business = form.cleaned_data[*'stage_business'*] > y.initial_idea = form.cleaned_data[*'initial_idea'*] > y.business_plan = form.cleaned_data[*'business_plan'*] > y.stage_website = form.cleaned_data[*'stage_website'*] > y.presence_on_social = form.cleaned_data[*'presence_on_social'*] > y.ventured_registered = form.cleaned_data[*'ventured_registered'*] > y.vent_type = form.cleaned_data[*'vent_type'*] > y.date_register = form.cleaned_data[*'date_register'*] > y.scope_services = form.cleaned_data[*'scope_services'*] > y.save() > request.session[*'funding'*] = y.funding > request.session[*' domain'*] = y.domain > request.session[*'initial_idea'*] = y.initial_idea > request.session[*'business_plan'*] = y.business_plan > request.session[*'stage_website'*] = y.stage_website > request.session[*'presence_on_social'*] = y.presence_on_social > request.session[*'ventured_registered'*] = y.ventured_registered > request.session[*'vent_type'*] = y.vent_type > request.session[*'date_register'*] = y.date_register > request.session[*'scope_services'*] = y.scope_services > *return *redirect(request,*'/form/5/'*,context={*'form'*:form}) > > > > *def *FormStep5View(request): > forms = FormStep5() > *return *render(request, *'form_5.html'*, context={*'form'*: forms}) > *def *addForm5(request): > form = FormStep5(request.POST) > *if *form.is_valid(): > a=modelstep5() > a.differentiators_business = > form.cleaned_data[*'differentiators_business'*] > a.explain_the_business_model = > form.cleaned_data[*'explain_the_business_model'*] > a.biggest_challenge_overcome = > form.cleaned_data[*'biggest_challenge_overcome'*] > a.biggest_mistake_amateur_entrepreneur = > form.cleaned_data[*'biggest_mistake_amateur_entrepreneur'*] > a.personally_bootstrapping_business = > form.cleaned_data[*'personally_bootstrapping_business'*] > a.entrepreneurial_funds = form.cleaned_data[*'entrepreneurial_funds'*] > a.save() > request.session[*'differentiators_business'*] = a.differentiators_business > request.session[*'explain_the_business_model'*] > =a.explain_the_business_model > request.session[*'biggest_challenge_overcome'*] = > a.biggest_challenge_overcome > request.session[*'biggest_mistake_amateur_entrepreneur'*] = > a.biggest_mistake_amateur_entrepreneur > request.session[*'personally_bootstrapping_business'*] = > a.personally_bootstrapping_business > request.session[*'entrepreneurial_funds'*] = a.entrepreneurial_funds > *return *redirect(request,*'/form/6/'*,context={*'form'*:form}) > > *def *FormStep6View(request): > forms = FormStep6() > *return *render(request, *'form_6.html'*, context={*'form'*: forms}) > *def *addForm6(request): > form = FormStep6(request.POST) > *if *form.is_valid(): > b=modelstep6() > b.plan_scaleup_business = form.cleaned_data[*'plan_scaleup_business'*] > b.trajectory_of_company = form.cleaned_data[*'trajectory_of_company'*] > b.biggest_achievement_venture = > form.cleaned_data[*'biggest_achievement_venture '*] > b.startup_recognized = form.cleaned_data[*'startup_recognized'*] > b.giving_up_and_doing_something = > form.cleaned_data[*'giving_up_and_doing_something'*] > b.save() > > request.session[*'plan_scaleup_business'*] = b.plan_scaleup_business > request.session[*'trajectory_of_company'*] = b.trajectory_of_company > request.session[*'biggest_achievement_venture'*] = > b.biggest_achievement_venture > request.session[*'startup_recognized'*] = b.startup_recognized > request.session[*'giving_up_and_doing_something'*] = > b.giving_up_and_doing_something > *return *redirect(request,*'/form/7/'*,context={*'form'*:form}) > > *def *FormStep7View(request): > forms = FormStep7() > *return *render(request, *'form_7.html'*, context={*'form'*: forms}) > > *def *addForm7(request): > form = FormStep7(request.POST) > *if *form.is_valid(): > c=modelstep7() > > c.rollercoaster_ride_of_entrepreneurship=form[*'rollercoaster_ride_of_entrepreneurship'*] > > c.vision_for_organization_2020=form.cleaned_data[*'vision_for_organization_2020'*] > > c.prestigious_awards_received=form.cleaned_data[*'prestigious_awards_received'*] > > c.recognition_that_you_value=form.cleaned_data[*'recognition_that_you_value'*] > > c.tips_budding_teenage_entrepreneurs=form.cleaned_data[*'tips_budding_teenage_entrepreneurs'*] > c.motivational_quote=form.cleaned_data[*'motivational_quote'*] > c.role_model=form.cleaned_data[*'role_model'*] > c.advisors_contribution=form.cleaned_data[*'advisors_contribution'*] > c.internships=form.cleaned_data[*'internships'*] > request.session[*'rollercoaster_ride_of_entrepreneurship'*] = > c.rollercoaster_ride_of_entrepreneurship > request.session[*'vision_for_organization_2020'*] = > c.vision_for_organization_2020 > request.session[*'prestigious_awards_received'*] = > c.prestigious_awards_received > request.session[*'recognition_that_you_value'*] = > c.recognition_that_you_value > request.session[*'tips_budding_teenage_entrepreneurs'*] = > c.tips_budding_teenage_entrepreneurs > request.session[*'motivational_quote'*] = c.motivational_quote > request.session[*'role_model'*] = c.role_model > request.session[*'advisors_contribution'*] = c.advisors_contribution > request.session[*'internships'*] = c.internships > *return *redirect(request,*'/form/8/'*,context={*'form'*:form}) > > > > *def *FormStep8View(request): > forms = FormStep8() > *return *render(request, *'form_8.html'*, context={*'form'*: forms}) > > > *def *addForm8(request): > form = FormStep8(request.POST) > *if *form.is_valid(): > d=modelstep8() > d.portraitphoto=form.ImageField(label=*'Portrait photos of yourself'*) > d.high_resolution=form.cleaned_data[*'high_resolution'*] > d.company_logo=form.cleaned_data[*'company_logo'*] > d.product_images=form.cleaned_data[*'product_images'*] > d.location_img=form.cleaned_data[*'location_img'*] > d.product_video=form.cleaned_data[*'product_video'*] > > d.customer_testimonial_video=form.cleaned_data[*'customer_testimonial_video'*] > > request.session[*'portraitphoto'*] = d.portraitphoto > request.session[*'high_resolution'*] = d.high_resolution > request.session[*'company_logo'*] = d.company_logo > request.session[*'product_images'*] = d.product_images > request.session[*'location_img'*] = d.location_img > request.session[*'product_video'*] = d.product_video > request.session[*'customer_testimonial_video'*] = > d.customer_testimonial_video > *return *redirect(request,*'/form/9/'*,context={*'form'*:form}) > > > *def *FormStep9View(request): > forms = FormStep9() > *return *render(request, *'form_9.html'*, context={*'form'*: forms}) > *def *addForm9(request): > form = FormStep9(request.POST) > *if *form.is_valid(): > e=modelstep9() > e.re_business=form.cleaned_data[*'re_business'*] > e.zoom_call=form.cleaned_data[*'zoom_call'*] > e.loc_head=form.cleaned_data[*'loc_head'*] > e.save() > request.session[*'re_business'*] = e.re_business > request.session[*'zoom_call'*] = e.zoom_call > request.session[*'loc_head'*] = e.loc_head > *return *redirect(request,*'/form/10/'*,context={*'form'*:form}) > > > *class *FormStep10View(request): > forms = FormStep10() > *return *render(request, *'form_10.html'*, context={*'form'*: forms}) > > *def *addForm10(request): > form = FormStep10(request.POST) > *if *form.is_valid(): > f=modelstep10() > f.story_published=form.cleaned_data[*'story_published'*] > f.social_media_published=form.cleaned_data[*'social_media_published'*] > f.save() > > request.session[*'story_published'*] = f.story_published > request.session[*'social_media_published'*] = f.social_media_published > > *return *redirect(request, *'display.html'*, context={*'form'*: form}) > *class *SuccessView(TemplateView): > template_name = *'success.html'* > > *urls.py* > > > > > > *from *django.urls *import *path > *from *django.contrib *import *admin > *from *django.views.generic *import *RedirectView > *from *mysite.core.views *import > *addForm1,addForm2,addForm3,addForm4,addForm5,addForm6,addForm7,addForm8,addForm9,addForm10,FormStep1View,FormStep2View,FormStep3View,FormStep4View,FormStep5View,FormStep6View,FormStep7View,FormStep8View,FormStep9View,FormStep10View > *from *mysite.core *import *views > > > urlpatterns = [ > path(*'admin/'*, admin.site.urls), > path(*''*, RedirectView.as_view(url=*'/form/1/'*), name=*'index'*), > path(*'form/1/'*, FormStep1View, name=*'form_1'*), > path(*'form/2/'*, FormStep2View, name=*'form_2'*), > path(*'form/3/'*, FormStep3View, name=*'form_3'*), > path(*'form/4/'*, FormStep4View, name=*'form_4'*), > path(*'form/5/'*,FormStep5View, name=*'form_5'*), > path(*'form/6/'*, FormStep6View, name=*'form_6'*), > path(*'form/7/'*, FormStep7View, name=*'form_7'*), > path(*'form/8/'*, FormStep8View, name=*'form_8'*), > path(*'form/9/'*, FormStep9View, name=*'form_9'*), > path(*'form/10/'*,FormStep10View, name=*'form_10'*), > > path(*'success/'*, views.SuccessView.as_view(), name=*'success'*), > > path(*'addForm1'*, addForm1), > path(*'addForm2'*, addForm2), > path(*'addForm3'*, addForm3), > path(*'addForm4'*, addForm4), > path(*'addForm5'*, addForm5), > path(*'addForm6'*, addForm6), > path(*'addForm7'*, addForm7), > path(*'addForm8'*, addForm8), > path(*'addForm9'*, addForm9), > path(*'addForm10'*, addForm10), > > ] > > -- > 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 django-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/4bf324e5-355d-4894-b54f-958e3f5fcd47%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/4bf324e5-355d-4894-b54f-958e3f5fcd47%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > -- > 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 django-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAMeub5O598kB0mRazwmvz_OEhtv0i9s7fXFaNitf%3D%3DPxPZLw9A%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAMeub5O598kB0mRazwmvz_OEhtv0i9s7fXFaNitf%3D%3DPxPZLw9A%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > > > -- > 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 django-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/5e4d77b8.1c69fb81.2a75b.0d4e%40mx.google.com > <https://groups.google.com/d/msgid/django-users/5e4d77b8.1c69fb81.2a75b.0d4e%40mx.google.com?utm_medium=email&utm_source=footer> > . > > -- > 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 django-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAD%3DM5eQdu3rDHpTmQW5utPUU_OnZc3ZEtLEL5f5_zX1cyOXJrg%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAD%3DM5eQdu3rDHpTmQW5utPUU_OnZc3ZEtLEL5f5_zX1cyOXJrg%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > > -- 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANvoF%2B9nADy_deB4ZoQDk_RS5a%3DVLAE0z7%2BFTVF5HYz-SZxwOQ%40mail.gmail.com.