problem resolved, here is how I did it, just a little change to my original
code, setattr by add_to_class, with this, I can add common attributes to lot
of models without having to inherit more than once or having a base class
for all my models :

def common_attrs(cls, common):
    attrs = dir(common)
    for attr in attrs:
        if isinstance( getattr(common, attr), models.Field ):
            #setattr( cls, attr, getattr(common, attr) )
            cls.add_to_class(attr, getattr(common, attr) )
    return cls

class Content:
    title = models.CharField( maxlength = 50 )
    description = models.CharField( maxlength = 100 )
    created_by = models.ForeignKey( User )
    creation_date = models.DateTimeField( auto_now_add = True )
    pub_date = models.DateTimeField()
    exp_date = models.DateTimeField()


class NewsItem(Content, models.Model):
    text = models.TextField()

    def __str__(self):
        return self.title

    class Admin: pass
NewsItem = common_attrs(News, Content)


On 6/5/07, Branton Davis <[EMAIL PROTECTED]> wrote:
>
>
> Cool!
>
>
> >
>


-- 
Lic. José M. Rodriguez Bacallao
Cupet

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to