views:

44

answers:

2

I've seen some nifty code on django-ratings documentation and like to create something similar. After googling around for now 2 weeks I got no idea on how to do this.

Maybe you could help me what to search for or where to get some docs?

Code from django-ratings docs:

...
response = AddRatingView()(request, **params)
    if response.status_code == 200:
        if response.content == 'Vote recorded.':
            request.user.add_xp(settings.XP_BONUSES['submit-rating'])
        return {'message': response.content, 'score': params['score']}
    return {'error': 9, 'message': response.content}
...

My Problem:

request.user.add_xp(settings.XP_BONUSES['submit-rating'])

So i'd like to do something like this:

request.user.my_shiny_function(foobar)

Thanks in advance, Thomas

A: 

I think the code sample you're sighting seems to have been picked from somewhere else (it's not part of the django-ratings code - a simple grep -ir "add_xp" on the source directory shows that text is only in Readme.rst).

If you could explain why you need the functionality you're looking for here, maybe we could help some more. In the mean time, you can look at rolling your own custom backend, extending the default User model and then adding other "nifty" features to it :).

Rishabh Manocha
+1  A: 

Check out proxy models: http://docs.djangoproject.com/en/dev/topics/db/models/#id8

Brian Luft