Re: 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

2020-02-19 Thread DHRUVA
How can I do ImageField and FileField in crispy forms

On Thu, 20 Feb, 2020, 12:53 AM ,  wrote:

>
>
> Yaa did that still facing issue
>
>
>
> *From: *onlinejudge95 
> *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 **class**="form-group col-md-4 mb-0"*>
> {{ form.email|as_crispy_field }}
>   
>   <*div **class**="form-group col-md-4 mb-0"*>
> {{ form.link_sent|as_crispy_field }}
>   
> <*button **type**="submit" **class**="btn btn-primary"*>Start
>  <*button **type**="submit" **class**="btn btn-primary"*>Save
>
>   
> {% endblock %}
>
>
>
>
>
> *From: *Farai M 
> *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 = 

RE: 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

2020-02-19 Thread dhruvashah1221999
 Yaa did that still facing issue From: onlinejudge95Sent: Thursday, February 20, 2020 12:32 AMTo: django-users@googlegroups.comSubject: 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  
No action attribute defined here. Where do you expect the data to be sent? {% csrf_token %} 
    {{ form.name|as_crispy_field }}  div> 
    {{ form.email|as_crispy_field }}  div> 
    {{ form.link_sent|as_crispy_field }}  div>   

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

2020-02-19 Thread onlinejudge95
On Wed, Feb 19, 2020 at 11:31 PM  wrote:

> 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 **class**="form-group col-md-4 mb-0"*>
> {{ form.email|as_crispy_field }}
>   
>   <*div **class**="form-group col-md-4 mb-0"*>
> {{ form.link_sent|as_crispy_field }}
>   
> <*button **type**="submit" **class**="btn btn-primary"*>Start
>  <*button **type**="submit" **class**="btn btn-primary"*>Save
>
>   
> {% endblock %}
>
>
>
>
>
> *From: *Farai M 
> *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'*]

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

2020-02-19 Thread dhruvashah1221999
The template file      {% csrf_token %}  
    {{ form.name|as_crispy_field }}  div> 
    {{ form.email|as_crispy_field }}  div> 
    {{ form.link_sent|as_crispy_field }}  div>   

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

2020-02-19 Thread dhruvashah1221999
 import os# Build paths inside the project like this: os.path.join(BASE_DIR, ...)BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))# Quick-start development settings - unsuitable for production# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/# SECURITY WARNING: keep the secret key used in production secret!SECRET_KEY = 'w(gn#4op(yq4-_@@z0zsw2-!c-ai4#wb48a1y^(ke)y)c1q('# SECURITY WARNING: don't run with debug turned on in production!DEBUG = TrueALLOWED_HOSTS = []# Application definitionINSTALLED_APPS = [    'django.contrib.admin',    'django.contrib.auth',    'django.contrib.contenttypes',    'django.contrib.sessions',    'django.contrib.messages',    'django.contrib.staticfiles',    'crispy_forms',    'mysite.core',]CRISPY_TEMPLATE_PACK = 'bootstrap4'MIDDLEWARE = [    'django.middleware.security.SecurityMiddleware',    'django.contrib.sessions.middleware.SessionMiddleware',    'django.middleware.common.CommonMiddleware',    'django.middleware.csrf.CsrfViewMiddleware',    'django.contrib.auth.middleware.AuthenticationMiddleware',    'django.contrib.messages.middleware.MessageMiddleware',    'django.middleware.clickjacking.XFrameOptionsMiddleware',]ROOT_URLCONF = 'mysite.urls'TEMPLATES = [    {    'BACKEND': 'django.template.backends.django.DjangoTemplates',    'DIRS': [    os.path.join(BASE_DIR, 'mysite/templates')    ],    'APP_DIRS': True,    'OPTIONS': {    'context_processors': [    'django.template.context_processors.debug',    'django.template.context_processors.request',    'django.contrib.auth.context_processors.auth',    'django.contrib.messages.context_processors.messages',    ],    },    },]WSGI_APPLICATION = 'mysite.wsgi.application'# Database# https://docs.djangoproject.com/en/2.1/ref/settings/#databasesDATABASES = {    'default': {    'ENGINE': 'django.db.backends.sqlite3',    'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),    }}# Password validation# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validatorsAUTH_PASSWORD_VALIDATORS = [    {    'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',    },    {    'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',    },    {    'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',    },    {    'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',    },]# Internationalization# https://docs.djangoproject.com/en/2.1/topics/i18n/LANGUAGE_CODE = 'en-us'TIME_ZONE = 'UTC'USE_I18N = TrueUSE_L10N = TrueUSE_TZ = True# Static files (CSS, _javascript_, Images)# https://docs.djangoproject.com/en/2.1/howto/static-files/STATIC_URL = '/static/' From: Farai MSent: Wednesday, February 19, 2020 11:19 PMTo: django-users@googlegroups.comSubject: 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. On Wed, Feb 19, 2020, 7:33 PM mick  wrote:  views.py from django.views.generic import FormView, TemplateViewfrom django.shortcuts import render,redirectfrom .models import modelstep1,modelstep2,modelstep3,modelstep4,modelstep5,modelstep6,modelstep7,modelstep8,modelstep9,modelstep10from .forms import FormStep1,FormStep2,FormStep3,FormStep4,FormStep5,FormStep6,FormStep7,FormStep8,FormStep9,FormStep10def 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']