Connect django project with sharepoint 2013

523 views
Skip to first unread message

Hossein Rashnoo

unread,
Dec 6, 2014, 7:10:43 AM12/6/14
to django...@googlegroups.com
I need to connect my project to sharepoint. So i installed "sharepoint 0.4.1" package and then use this code in my view :

from sharepoint import SharePointSite, basic_auth_opener

def userloginres(request):
server_url = "http://portal:8080/"
site_url = server_url + "rashno/"
opener = basic_auth_opener(server_url, "my username", "my password")
site = SharePointSite(site_url, opener)

htt=r"<h2>Sharepoint lists</h2><ul>"
for sp_list in site.lists:
htt = htt + r"<li> %s ..... %s </li>" % (sp_list.id,sp_list.meta['Title'])
htt = htt + r"</ul>"

t = get_template('userlogin/userloginres.html')
html= t.render(Context({"htt":htt}))
return HttpResponse(html)

But now when i open that url this error appear:

URLError at /test/login/

<urlopen error [Errno -2] Name or service not known>

François Schiettecatte

unread,
Dec 6, 2014, 7:49:45 AM12/6/14
to django...@googlegroups.com
Ok, but I am not sure what this has to do with Django ? Maybe you should ask on a SharePoint mailing list ? And did you try running the code in a script on the command line ?

François
> --
> 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...@googlegroups.com.
> To post to this group, send email to django...@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/a982dfcf-6824-441a-ab5f-f68907e1f0d7%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Hossein Rashnoo

unread,
Dec 6, 2014, 11:46:23 PM12/6/14
to django...@googlegroups.com
I need this connection for adding list items and save my users data on sharepoint database. I ran it in command line and when i write something like """ print site.lists[0] """ this error appear :


  File "<console>", line 1, in <module>
  File "/usr/lib/python2.6/site-packages/sharepoint/lists/__init__.py", line 84, in __getitem__
    return self.all_lists[key]
  File "/usr/lib/python2.6/site-packages/sharepoint/lists/__init__.py", line 36, in all_lists
    result = self.opener.post_soap(LIST_WEBSERVICE, xml)
  File "/usr/lib/python2.6/site-packages/sharepoint/site.py", line 31, in post_soap
    response = self.opener.open(request)
  File "/usr/lib64/python2.6/urllib2.py", line 391, in open
    response = self._open(req, data)
  File "/usr/lib64/python2.6/urllib2.py", line 409, in _open
    '_open', req)
  File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 1190, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib64/python2.6/urllib2.py", line 1165, in do_open
    raise URLError(err)
URLError: <urlopen error [Errno -2] Name or service not known>

Mario Gudelj

unread,
Dec 7, 2014, 12:00:18 AM12/7/14
to django...@googlegroups.com

Urllib2 can't open the url http:// portal:8080. I assume that you can't visit that url from the browser either

Hossein Rashnoo

unread,
Dec 7, 2014, 12:46:51 AM12/7/14
to django...@googlegroups.com
I can access to http://portal:8080/ in my browser when i set our office proxy and port. And my linux server that i run django on it, is local. Do i need to set proxy to access sharepoint?

Mario Gudelj

unread,
Dec 7, 2014, 7:46:29 AM12/7/14
to django...@googlegroups.com

Well your python code is trying access that url so the url must work

Collin Anderson

unread,
Dec 9, 2014, 8:42:16 AM12/9/14
to django...@googlegroups.com
Hi,

You may have better luck using the ip address directly instead of "portal".

Collin
Reply all
Reply to author
Forward
0 new messages