It will be different depending on the database (assuming you are asking about the query only). You will need to do an order by on either your auto incremented field or dat field plus something like a limit 2 (Postgres and I believe MySQL) or top 2 for something like SQL Server. On Jun 18, 2014 8:14 AM, "Ilya Kazakevich" <ilya.kazakev...@jetbrains.com> wrote:
> You probably need to have "insert_date" field and store entry created date > there. > > > Ilya Kazakevich, > JetBrains PyCharm (Best Python/Django IDE) > http://www.jetbrains.com/pycharm/ > "Develop with pleasure!" > > > >-----Original Message----- > >From: django-users@googlegroups.com > >[mailto:django-users@googlegroups.com] On Behalf Of Ashu Singh > >Sent: Wednesday, June 18, 2014 4:03 PM > >To: django-users@googlegroups.com > >Subject: Database problem in Django > > > >Hello everyone. My doubt is how to fetch the recent two database entries > in > >django. User may enter into database anytime but the query should always > fetch > >last two entries. > > > > > >-- > >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 > >django-users+unsubscr...@googlegroups.com. > >To post to this group, send email to django-users@googlegroups.com. > >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/bdd16e14-ef35-4125-966d-60 > >6d36f93fd0%40googlegroups.com > ><https://groups.google.com/d/msgid/django-users/bdd16e14-ef35-4125-966d-6 > >06d36f93fd0%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 django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > 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/017701cf8aee%24d51d7200%247f585600%24%40JetBrains.com > . > 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 django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. 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/CAA_%3DsbR4Hy3b5vsb7-6TaX3ne6Tkfa6qXmvDBcjtdqsDuSTqMA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.