I have a model that contains alphanumeric protein names e.g. ('Ypp1Aa100"). I have to properly sort it when returning the contents to the html. I found some fantastic sorting examples from this blog post https://blog.codinghorror.com/sorting-for-humans-natural-sort-order/
. I have a sorting function in the view that sorts well and returns the contents to the html. This works really well for my template tag display.
However, depending upon the proteins (mutant or not) I need a different href. Hence, I have used a function in the django model as below
proteins = ProteinDatabase.objects.all()
mutants = MutantProteinDatabase.objects.all()
for protein in proteins:
for mutant in mutants:
Then, I updated the template tag like below
However, my sorting doesn't work in the above template tags (due to if else). If I use only one href it sorting works perfectly well.
To sum it up. I have a model named ActivityDatabase. In this model I have to check whether it is mutant or not from the other two databases (ProteinDatabase and MutantDatabase). If it is a mutant protein it has to have a different href (/protein_detail/ and /mutant_detail/). In addition , I have a natural sort function in the views that sorts by alphanumeric proteins. I also use DataTables js to display my contents (for extra detailed information) https://datatables.net/examples/api/row_details.html
. There is also natural sorting in the datatables example which doesn't suit my needs.
Can you please suggest some pointers to think of any other logic for this problem? I use Django 3.2.