Skip to content Skip to sidebar Skip to footer

How To Enumerate New Column?

In my Django admin I have a TabularInLine class. In the picture, each element of this class is numbered with it's own ID. This TabularInLine class has a foreign key to an other cla

Solution 1:

you can define your own insert operation which does those steps:

  • query database with your new entry's foreign key
  • get count of results
  • assign my_id=count+1

let's say you already have that table in your database. you want to add a new entry to database, which has FK="three".

  • query DB for objects(FK="three").
  • count of results is 2. (the last two rows)
  • assign my_id=3

Post a Comment for "How To Enumerate New Column?"