I can see two ways to achieve what you seem to want:
1. Add fields after the model has been created
This method uses an only unofficially documented feature[1] of
Django's model field classes.
class MyModel(models.Model):
# a few fields
for field in fields:
MyModel.add_to_class(field, models.DecimalField(decimal_places=4,
max_digits=10))
2. Construct a new type dynamically
class Meta:
verbose_name = _('my model')
attrs = {
'__module__': 'mymodule',
'Meta': Meta,
'method1': method1,
# ... more fields and methods
}
for field in fields:
attrs[field] = models.DecimalField(...)
MyModel = type('MyModel', (models.Model,), attrs)
Of course, the usual caveats apply. It might make your code harder to
read and understand, and harder to debug too, because it is not clear
what model fields exist by simply looking at the model code (that
applies especially to method 1)
Matthias
[1]: It's documented in Marty Alchin's excellent Pro Django book. I
think we can assume that this method won't go away without very good
reasons(tm).