django: Selecting questions that was not asked
        Posted  
        
            by Oleg Tarasenko
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Oleg Tarasenko
        
        
        
        Published on 2010-03-11T20:34:52Z
        Indexed on 
            2010/03/11
            20:39 UTC
        
        
        Read the original article
        Hit count: 267
        
Hi,
I am creating small django application which holds some few questions (and answers for them)
What I want to do is to show user random question, but only from those which was not solved by him yet. I wonder how to do this.
For now, I defined user profile model this way:
class UserProfile(models.Model):
    rank = models.IntegerField(default = 1)
    solvedQ = models.ManyToManyField(Question)
    user = models.ForeignKey(User, unique=True)
So solved problems are added this way:
if user.is_authenticated():
    profile = user.get_profile()
    profile.rank += 1
    profile.solvedQ.add(Question.objects.get(id=id))
Now if the view must show random question, but not from already solved list...
Is there a good way to intersect Questions and solvedQuestions.... so question is chosen from the unsolved list?
© Stack Overflow or respective owner