Tag Info

Currently in Django 1.7...
I think the workaround you defined is the only valid solution (besides from a monkey patch) currently when using the Django auth login() method. I'm just going to assume you are using the standard login() method which is raising this exception.
If we take a look at the source for the login method, we find at the end of the ...

You don't seem to be asking about your actual problem. The error you mention is because you seem to be explicitly setting groups to an empty list if the user is anonymous. But you are also quite clear what you actually want to happen, which is to send the user to a login page. So why didn't you ask about that?
As Raja says, the solution to that problem is ...

In my opinion you could use a LoginRequiredMiddleware in order to check that user authenticated in every possible view. If not then redirect him to login page.
https://djangosnippets.org/snippets/1179/
Edit:
When it comes to authenticating users you should look these tutorials:
How to properly use the django built-in login view
homepage login form ...

This is not strictly cannon, but to avoid creating a new User class or Auth backend, I tend to let users log in with both username or email.
Anyways you'll want to ensure emails are unique as django does not check this by default.
You'll then have to override the default login view to support this. You can create something along the lines of:
class ...

The answer is directly in django documentation, in short words you should subclass AbstractBaseUser or AbstractUser (in second case you can't totally remove username field), create your own user manager based on BaseUserManager or UserManager and customize built-in auth forms if you're using it (or any app that you're using is using it).

If I understand you correctly - you can leave AUTH_LDAP_BIND_PASSWORD as blank in settings.py, and update it in your view with user-submitted password in a form before calling authenticate() method, like this:
def auth_and_login(request, onsuccess='/', onfail='/login/'):
if request.method == 'POST':
username = request.POST['user']
...

First run
Show login Activity
Send credentials to server
Get a session_key
User is authenticated, exit the login Activity
you get the access tokens and login details to stored in Shared Preferences
For other request.
Add a header with session_key to your request (e. g. as a header)
Send the request

To authenticate users using the university API, all you need to do is to write an authentication backend. You can then create a local user for these uni users the first time they login, since there is only two required fields: username and password. You can use set_unusable_password() so check_password() for this user will never return True.
The Django ...

If you are using django rest framework, then you basically want to have an update method on your view class for UserProfile that takes in the user id as a request param. Then in that method you want to use the ORM to get a model object for the given userprofile id, set the property that was also passed as a param, and save the changed model object. Then ...

You could write a custom view which would look like def vote(request, model, object_id, value) from the external app, but without this piece of code in it:
if not request.user.is_authenticated():
return HttpResponse(status=401)
Also make sure, that you map your custom view to the correct url instead of including app's urls:
url(r'^vote/$', ...

User's group list is available as the user.groups related manager:
def user(request):
context = {'user': request.user,
'groups': request.user.groups.all()}
return render_to_response('username.html', context,
context_instance=RequestContext(request))
To display this list in the template you have to loop ...

This error appears when the provided login credentials are not valid.
Check the followings:
your user exists in the auth_user table of the database and the is_active field is set to 1?
your password is correct?
your user has a token in the authtoken_token table?.

Edit
There is your problem, in urls, you are pointing not to a view, but to a User. Python is case sensitive, you know. :)
Your problem is instead of response, middleware is getting a User object, so somwhere, instead of response you are returning a user, I don't see it in your code though.
Regardless, why don't you use django's authentication views? ...

User model has many-to-many relation with Group model that has unique name field. I would leave logic for checking user group in view and pass simple context variable with group name to template like in your example usergroup and check it as you already mentioned with if and elif template tags.