tag:blogger.com,1999:blog-4477131926658044957.post87045814718207399..comments2023-05-28T03:47:58.240-07:00Comments on pydanny: My BaseModelpydannyhttp://www.blogger.com/profile/00481523876497446983noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-4477131926658044957.post-3233475459126780822011-12-15T06:53:36.087-08:002011-12-15T06:53:36.087-08:00Diederik van der Boor,
auto_add_now and auto_add ...Diederik van der Boor,<br /><br />auto_add_now and auto_add are deprecated. We aren't supposed to use them anymore. :Dpydannyhttps://www.blogger.com/profile/00481523876497446983noreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-54872902839535073082011-12-09T08:03:34.090-08:002011-12-09T08:03:34.090-08:00Awesome idea to have the creationdate and modifica...Awesome idea to have the creationdate and modificationdate as base class fields.<br /><br />In the recent Django versions (1.2?) it is no longer needed to have separate fields. You could also use:<br /><br />created = DateTimeField(_('created'), auto_now_add=True)<br />modified = DateTimeField(_('modified'), auto_now=True)<br /><br />Making the code even easier :-)Diederik van der Boorhttps://www.blogger.com/profile/11435808496879023545noreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-4621273868590502672011-12-09T07:55:17.349-08:002011-12-09T07:55:17.349-08:00@John - I think this got added to django_extension...@John - I think this got added to django_extensions after I created my BaseModel class. But it's a wonderful development and I'm happy!pydannyhttps://www.blogger.com/profile/00481523876497446983noreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-47830629826628230042011-12-09T07:42:06.363-08:002011-12-09T07:42:06.363-08:00I don't think you need your BaseModel abstract...I don't think you need your BaseModel abstract class at all as you don't need to add `created` and `modified` manually, just subclass the TimeStampedModel in django_extensions. I do this and don't need to do anything special to use south.<br />See http://packages.python.org/django-extensions/model_extensions.html<br /><br /> from django_extensions.db.models import TimeStampedModel<br /> class MyModel(TimeStampedModel):<br /> # model now has 'created' and 'modified' fields<br /> passJohnhttp://www.dive-reviews.comnoreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-32654680417438252902011-12-09T07:37:32.906-08:002011-12-09T07:37:32.906-08:00Carl's django-model-utils provides similar aut...Carl's <a href="https://bitbucket.org/carljm/django-model-utils/src" rel="nofollow">django-model-utils</a> provides similar auto fields and base models that play nice with south. Might be worth checking out :)Sean O'Connorhttps://www.blogger.com/profile/00622400212588601248noreply@blogger.com