在 2015年4月29日星期三 UTC+8下午6:32:09,Tom Evans写道:
>
> On Wed, Apr 29, 2015 at 11:06 AM, 田福顿 <[email protected] <javascript:>> 
> wrote: 
> > I want to connect to tables than get their complment, but I don't know 
> how 
> > to do it? Plaea give me some suggestion. I have wasted two days in this 
> > problem.BTW this way didn't work:Django: Getting complement of queryset 
>
> That is how to do it. What doesn't work? Show an example.. 
>
> Tom 
>

this is my code 
if StudyRecord.objects.filter(id = i_d ).exists():
            current=StudyRecord.objects.get(id = i_d )
            if PersonalRecord.objects.filter(book = current.book,user_id = 
current.id).exists():
                p_r = PersonalRecord.objects.filter(book = current.book,id 
= i_d)
                for iterm in p_r:
                words = WordBase.objects.filter(belong = current.book)
                new_words=WordBase.objects.filter(belong = 
current.book).exclude(number__in=p_r.values_list('number', flat=True))[:1]
                for single_words in new_words:                 
                    u1 = PersonalRecord(user_id = request.user.id,begtime= 
time.time(),
                                                
endtime="",lasttime="",times = 0, status = 0,
                                                number = 
single_words.number,book = single_words.belong,
                                              ) 
                    u1.save()
            else:
                new_words = WordBase.objects.filter(belong = current.book 
)[:5]
                return HttpResponse("fail")
                for single_words in new_words:              
                    u1 = PersonalRecord(user_id = request.user.id,begtime= 
time.time(),
                                        endtime="",lasttime="",times = 1, 
status = 0,
                                        number = single_words.number,book = 
single_words.belong,)                                               
                    u1.save()
            
but, it didn't work, it still save the record that the database already have
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/edc37582-c299-47d9-9d86-97ceab2de53a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to