python - Django: <view_name> takes exactly 4 arguments (1 given) -
my application has form redirects form based on condition (the first form evangelizedform
, , second conditional form socialaccountsform
)
def fillform(request): if request.method == 'post': form = evangelizedform(request.post) if form.is_valid(): obj = form.save(commit=true) . . . return redirection(request, first_name, last_name, email, other_social_accounts)
the view fillform
view handles processing of first form. on successful submission of form, redirects redirection
view:
def redirection(request, first_name, last_name, email, other_social_accounts): if other_social_accounts == 'yes': return yes_social(request, first_name, last_name, email)
based on value of other_social_accounts
form field in original post, control of program transferred yes_social
view:
def yes_social(request, first_name, last_name, email): if request.method == 'post': form = socialaccountsform(request.post) if form.is_valid(): obj = form.save(commit=true) obj.first_name = first_name obj.last_name = last_name obj.email = email obj.save() else: form.errors else: form = socialaccountsform() context = requestcontext(request, {'request': request, 'form': form}) return render_to_response('rango/yes_social.html', context_instance = context)
yes_social.html
<form id="evangelized_form" method="post"> <!-- name: <input type = "text" name = "name" value = "{{user.get_full_name}}"><br> --> {% csrf_token %} {% hidden in form.hidden_fields %} {{ hidden }} {% endfor %} {% field in form.visible_fields %} <div id = "err">{{ field.errors }}</div> <b>{{ field.help_text }}</b><br> {{ field }}<br><br> {% endfor %} <input type="submit" name="submit" value="submit" /> </form>
basically, want store values of first_name
, last_name
, email
form fields taken first form along data submitted second form database. hence code:
if form.is_valid(): obj = form.save(commit=true) obj.first_name = first_name obj.last_name = last_name obj.email = email obj.save()
however, on submitting second form, following error:
yes_social() takes 4 arguments (1 given)
now, realize on submission of second form, variables first_name
, last_name
, email
not passed view, , hence raises above mentioned error.
what changes can make in code store values of first_name
, last_name
, email
taken first form , store in database values submitted second form?
edit 1:
urls.py
from django.conf.urls import patterns, url rango import views urlpatterns = patterns('', url(r'^$', views.index, name = 'index'), url(r'^fillform/$', views.fillform, name='fillform'), url(r'^redirection/$', views.redirection, name='redirection'), url(r'^yes_social/$', views.yes_social, name='yes_social'),)
Comments
Post a Comment