try latest_message = Message.objects.filter(example_field=1)[::-1].first()
On Mon, Sep 24, 2018 at 5:55 AM <[email protected]> wrote: > I am a python developer and I am using Django 1.9.8 for my project. > I am having a problem with MySQL like below: > > I have a model named 'Message' and sometimes when running this code, I got > the exception 'Commands out of sync; you can't run this command now' > > latest_message = > Message.objects.order_by("-id").filter(example_field=1).first() > > can you point out to me why does it happen and how to fix it? > thanks, > Thanh Tran > > -- > 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 https://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/740fac2d-3399-45d3-bd96-54a76e7f2335%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/740fac2d-3399-45d3-bd96-54a76e7f2335%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHV4E-ch5LVk%2BkFTFw12A5Bnkah7ALc2r97Y8G_imHjXcikAsg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

