my code:
for name, count1 in list:
s = Keywords(file_name=name,frequency_count=count1)
s.save()
this is a section of code in views.py file of my app created in django. In this section, it is the way I’m storing the data in the table. This data is stored in the increasing order of the filenames which I do not want. I tried using order_by() function without any arguments but no effect. The data is still stored in increasing order. Please suggest some solution.
I’m new to django and sqlite3. So,
please help.
Order is inextricable. The queryset is always going to be ordered by something, even if it’s just the default of the primary key. This is really a database thing more than a Django thing. Databases inherently order data by the primary key unless told to order by something else. If you want truly random ordering, then you can use
order_by('?'), but that significantly increases the work the the database has to do.