python - Conrtoller for "right answer" -


i'm developing project http://stackoverflow.com. so, questions , answers. i'm trying find out realization of "right answer". i'm using django.
here model "answer":

class answer(models.model):     question = models.foreignkey(question)     content = models.textfield()     author = models.foreignkey(user)     date = models.datetimefield(db_index=true, default=datetime.now())     is_right = models.booleanfield(default=false)     ratio = models.integerfield(db_index=true, default=0) 

i'm interested in controller define "right answer" , "on html-page" realization.

a controller mark answer right can simple as

def mark_right(answer_id):   try:     answer = answer.objects.get(pk=answer_id)   except answer.doesnotexist:     raise http404   answer.is_right = true   answer.save() 

additionally, askbot functional stackoverflow clone, written in django https://github.com/askbot/askbot-devel


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -