FAQ
My view:

@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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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.

Search Discussions

  • Tom Evans at Oct 30, 2013 at 1:59 pm

    On Wed, Oct 30, 2013 at 1:44 PM, Nigel Legg wrote:
    My view:

    @login_required
    def list(request):
    user = User.objects.get(pk=request.session['user.id'])
    What is putting this 'user.id' key in the session? d.c.auth puts
    "_auth_user_id" in the session (but if the 'user' is the logged in
    user, why any of this, why not request.user?)

    Cheers

    Tom

    --
    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+unsubscribe@googlegroups.com.
    To post to this group, send email to django-users@googlegroups.com.
    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/CAFHbX1%2BqLWiu2Q9aATFD9A7uM5ahkuE7CNJdNiQ%2BdwLqQwXYOg%40mail.gmail.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Nigel Legg at Oct 30, 2013 at 3:14 pm
    I'll try that, but why does this work under windows and not ubuntu
    On 30 Oct 2013 13:59, "Tom Evans" wrote:
    On Wed, Oct 30, 2013 at 1:44 PM, Nigel Legg wrote:
    My view:

    @login_required
    def list(request):
    user = User.objects.get(pk=request.session['user.id'])
    What is putting this 'user.id' key in the session? d.c.auth puts
    "_auth_user_id" in the session (but if the 'user' is the logged in
    user, why any of this, why not request.user?)

    Cheers

    Tom

    --
    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+unsubscribe@googlegroups.com.
    To post to this group, send email to django-users@googlegroups.com.
    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/CAFHbX1%2BqLWiu2Q9aATFD9A7uM5ahkuE7CNJdNiQ%2BdwLqQwXYOg%40mail.gmail.com
    .
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    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+unsubscribe@googlegroups.com.
    To post to this group, send email to django-users@googlegroups.com.
    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/CADeX7vw1QF6DXg5k0S0a-a%3DQgp7MQq0rY5GFEDD6K46rA-VRBg%40mail.gmail.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdjango-users @
categoriesdjango, python
postedOct 30, '13 at 1:44p
activeOct 30, '13 at 3:14p
posts3
users2
websitedjangoproject.com

2 users in discussion

Nigel Legg: 2 posts Tom Evans: 1 post

People

Translate

site design / logo © 2022 Grokbase