I'm use Django-hstore library, and there is pretty admin widget. The subject table store computer's components, something like this:
class Component(models.Model):
name = models.CharField(max_length=64)
purchase_date = models.DateField(blank=True, null=True)
product_page = models.URLField(blank=True, help_text='url to pruduct page')
<...>
data = hstore.DictionaryField(blank=True)
def load_cpu_data(self):
if self.product_page:
info = cpu_data(self.product_page)
if info: # info is a SortedDict with proper order
for key, value in info.items():
self.data[key] = value
self.save()
Next, I get data from cpu-world.com
about necessary CPU and I have following inline data in admin:
Look great, but sorting alphabetically instead logical, in order of loading data into database in load_cpu_data
model method. Example of proper order, like on cpu-world:
Family
Model number
Frequency
Socket
Microarchitecture
Processor core
Manufacturing process
Data width
The number of CPU cores
The number of threads
Integrated graphics
Thermal Design Power
Is there technique, or trick, or something to help me show data in desired sequence? For example, I found python OrderedDict data type, which similar to what I need. But apparently hstore inner structure mess data order.