@login_required
def list(request):
user = User.objects.get(pk=request.session['user.id'])
# Handle file upload
if request.method == 'POST':
form = dataFileForm(request.POST, request.FILES)
if form.is_valid():
newdat = dataFiles(datafile = request.FILES['datafile'])
newdat.user_id = user
newdat.save()
# Redirect to the document list after POST
return HttpResponseRedirect(reverse('tilda.myapp.views.list'))
else:
form = dataFileForm() # A empty, unbound form'''
# Load documents for the list page
datafiles = dataFiles.objects.all()
# Render list page with the documents and the form
return render_to_response(
'myapp/list.html',
{'datafiles': datafiles, 'form': form, },
context_instance=RequestContext(request)
)
Under Windows7, using Python 2.7.5, with MySQL, this works after login,
showing a list of files already uploaded and the form to upload a new
file.
I have now moved the app onto Ubuntu 13.04, using Python 2.7.4 with
Postgres 9.1 (in reparation for a test deployment to Heroku), using
vrtualenv. Following login, when I try and access this page, I get: Key
Error at myapp/list: 'user.id'.
I cant find a reason for this not working, can anyone help?
Cheers, Nigel
07914 740972
--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADeX7vy_DQ7szJTdmKsosyfrAwx5mQgLaspFD%3Dp%2BeYzvK%2Buo_w%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.