django - Dictionary update sequence element #1 has length 4; 2 is required -
i using django 1.8.4, when tried run website on browser gave me error "valueerror @ /artists/create dictionary update sequence element #1 has length 4; 2 required
request method: request url: http://127.0.0.1:8000/artists/create django version: 1.8.4 exception type: valueerror exception value: dictionary update sequence element #1 has length 4; 2 required python version: 2.7.10 python path: ['c:\\users\\juliks\\documents\\visual studio 2015\\projects\\musicstore\\musicstore', 'c:\\windows\\system32\\python27.zip', 'c:\\users\\juliks\\documents\\visual studio 2015\\projects\\musicstore\\musicstore\\env\\dlls', 'c:\\users\\juliks\\documents\\visual studio 2015\\projects\\musicstore\\musicstore\\env\\lib', 'c:\\users\\juliks\\documents\\visual studio 2015\\projects\\musicstore\\musicstore\\env\\lib\\plat-win', 'c:\\users\\juliks\\documents\\visual studio 2015\\projects\\musicstore\\musicstore\\env\\lib\\lib-tk', 'c:\\users\\juliks\\documents\\visual studio 2015\\projects\\musicstore\\musicstore\\env\\scripts', 'c:\\python27\\lib', 'c:\\python27\\dlls', 'c:\\python27\\lib\\lib-tk', 'c:\\users\\juliks\\documents\\visual studio 2015\\projects\\musicstore\\musicstore\\env', 'c:\\users\\juliks\\documents\\visual studio 2015\\projects\\musicstore\\musicstore\\env\\lib\\site-packages']
how solve error? thank you.
yes using visual studio. here code views.py --> """ definition of views. """
from django.shortcuts import render, render_to_response django.http import httprequest, httpresponse, httpresponseredirect django.template import requestcontext datetime import datetime app.models import *; def artistcreate(request): if request.method == "get": form = artistform(); return render(request, 'app/create.html', { 'form', form }); elif request.method == "post": form = artistform(request.post); form.save(); return httpresponseredirect('/artists'); def artists(request): #return httpresponse('<html><head><title>hello django! </title></head><body><h1>hello, django</h1></body></html>'); artists = artist.objects.all(); return render_to_response('app/artists.html', { 'artists': artists }); def artistdetails(request, id): artist = artist.objects.get(pk = id); return render_to_response('app/artistdetails.html', {'artist', artist}); def home(request): """renders home page.""" assert isinstance(request, httprequest) return render( request, 'app/index.html', context_instance = requestcontext(request, { 'title':'home page', 'year':datetime.now().year, }) ) def contact(request): """renders contact page.""" assert isinstance(request, httprequest) return render( request, 'app/contact.html', context_instance = requestcontext(request, { 'title':'contact', 'message':'your contact page.', 'year':datetime.now().year, }) ) def about(request): """renders page.""" assert isinstance(request, httprequest) return render( request, 'app/about.html', context_instance = requestcontext(request, { 'title':'about', 'message':'your application description page.', 'year':datetime.now().year, }) )
Comments
Post a Comment