0

This is my model.py code

class Question(models.Model):
id = models.AutoField
    question = models.CharField(max_length=100)
    answer =  models.CharField(max_length=100)
class TestSeries(models.Model):

    id = models.AutoField
    quiz_name = models.CharField(max_length=100)
    all_question=models.ManyToManyField(MyQuestion)

When i open my admin panel on test series previous added are shown in order : Oldest first

I want to see that in newest first manner.

Gonçalo Peres
  • 11,752
  • 3
  • 54
  • 83
Raj Subh
  • 17
  • 3

1 Answers1

0

There are two things OP needs to do

  1. Store in the models when the object was created / updated.

  2. Order based on the creation date. To do so, one can add to the model a Meta option named ordering or define a custom form to be used in the Django Admin. Example 1, Example 2.

Gonçalo Peres
  • 11,752
  • 3
  • 54
  • 83
  • We need to apply ordering = creation date , in TestSeries admin register or Question admin register . we want to order based on creation date under test series , when selecting questions – Raj Subh Sep 17 '22 at 09:28
  • @RajSubh add in both, it's a good standard as well. – Gonçalo Peres Sep 17 '22 at 09:43