On Tue, Mar 13, 2012 at 8:54 PM, hack <scottma...@gmail.com> wrote:

> This stuff is killing me.  LOL  I think I just don't understand the
> urllib2 yet.
>
> I'm trying something very simple, but am having a terrible time
> figuring out how to get it to work in python and django.  All I want
> to do is post to my site with params.  Here is what I have:
>
> def test(request):
>        test = " NOTHING "
>        if request.method=='POST':
>                test = request.POST.get('test',None)
>                print 'data posted'
>                print 'test param: ',test
>
>        return HttpResponse("Text only, please."+str(test),
> content_type="text/plain")
>
> Here is how I'm trying to call it via IDLE:
>
> >>> parms = urllib.urlencode([('test','testing'),('test2','testing2')])
> >>> print parms
> test=testing&test2=testing2
>
> >>> response = urllib2.urlopen('http://my.ip.address:8080/myapp/test/
> ',parms)
>
> Heres the error:
> Traceback (most recent call last):
>  File "<console>", line 1, in <module>
>  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/
> python2.6/urllib2.py", line 124, in urlopen
>    return _opener.open(url, data, timeout)
>  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/
> python2.6/urllib2.py", line 389, in open
>    response = meth(req, response)
>  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/
> python2.6/urllib2.py", line 502, in http_response
>    'http', request, response, code, msg, hdrs)
>  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/
> python2.6/urllib2.py", line 427, in error
>    return self._call_chain(*args)
>  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/
> python2.6/urllib2.py", line 361, in _call_chain
>    result = func(*args)
>  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/
> python2.6/urllib2.py", line 510, in http_error_default
>    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
> HTTPError: HTTP Error 403: FORBIDDEN
>


Can you check if development mode, check csrf ?

Regards,

>
> Any advice is greatly appreciated.  Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Cristian Salamea
@ovnicraft

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to