from django.db import models
# Start with models.Model
# examine all immediate subclasses using models.Model.__subclasses__()
# then examine each to see if it has a 'objects' attribute => data table
# if so, add to list of models we can plot with
# then examine its subclasses to see if we can find any more models
MODELS=[]
PLOT_TYPES=[]
class Dataplot(models.Model):
"""Plot of every instance in model.
"""
model=models.CharField(max_length=255,choices=MODELS)
type=models.CharField(max_length=255,choices=PLOT_TYPES)
class Admin:
pass
def get_plot(self):
pass
def save(self):
super(Dataplot,self).save()
P=self.get_plot()
kwargs=P.get_kwargs()
for k,v in kwargs:
A,C=self.argument_set.get_or_create(key=k)
if C:
A.value=v
A.save()
class Argument(models.Model):
"""Named argument to pass to dataplot function.
"""
dataplot=models.ForeignKey(Dataplot,edit_inline=True,num_in_admin=0)
key=models.CharField(max_length=255,null=False,default='',core=True)
value=models.CharField(max_length=255,null=False,default='',core=True)