Maybe a stupid question: Requests (Python HTTP lib) support Django 1.4?
I use Queries following the official quick launch as shown below:
requests.get('http://127.0.0.1:8000/getAllTracks', auth=('myUser', 'myPass'))
but i never get authentication. (Of course, I checked the URL, username, password again and again.)
The above URL ' http://127.0.0.1:8000/getAllTracks ' matches the url.py template of the Django project, and this url template callback is getAllTracks ' of the Django application.
If I comment on the authentication code " getAllTracks ", then the above code works fine, but if I add this authentication code for the submission, then the specified code will never be authenticated to the right.
The authentication code is actually very simple, as shown below (second line):
def getAllTracks(request):
if request.user.is_authenticated():
tracks = Tracks.objects.all()
if tracks:
This means that if I delete the second line above (with some indentation adjustments, of course), then the request.get () operation does what it needs for me, but if not (keep the second line) then it will never be right .
Any help would be appreciated.
source
share