this is the setting.pydef addProfile(request):try:userProfile = UserProfile.objects.get(user=request.user)return {'user_profile':userProfile}except:return {}
TEMPLATE_CONTEXT_PROCESSORS = ('django.contrib.auth.context_processors.auth','django.contrib.messages.context_processors.messages','social_auth.context_processors.social_auth_by_type_backends','earth.context_processors.addProfile',)
mapped as$.post("/geoloc/updateloc/", { latitude: lat, longitude: lon });
url(r'^geoloc/updateloc/$', 'earth.views.updateLoc'),
and here is the view:
the fact is that in the view, the request.user_profile (which should be loaded by the context template) is empty or none. basically if i print it i don't have anything printed.@login_required@csrf_protectdef updateLoc(request):message={}message['status']='ko'if request.is_ajax():if request.method == 'POST':message['status']='ok'userProfile = request.user_profileuserProfile.latitude=request.POST['latitude']userProfile.longitude=request.POST['longitude']userProfile.save()# Here we can access the POST datareturn HttpResponse(json.dumps(message), mimetype="application/json")
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/SrWWDpVQ-joJ.--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
ok,but in this way when the user logs out i've to remove the object from the request, right?what if the user closes the browser?