I have a date_added
field for my entries and it's frustrating clicking the date and time when filling these in. I want this to happen behind the scenes and I don't want these to even show up.
I've googled around and tried searching SO but was unable to find a snippet of how this can be done when I save my form.
Here's the relevant bit from admin.py
:
class BugForm( forms.ModelForm ):
class Media:
#js = ( 'http://static.arounds.org/wmd/wmd.js', )
js = ( 'http://ajax.googleapis.com/ajax/libs/mootools/1.2.3/mootools-yui-compressed.js', 'http://static.arounds.org/js/moowmd.js', 'http://static.arounds.org/js/wmd-config.js' )
css = {
'all': ('http://static.arounds.org/css/wmd.css',)
}
class Meta:
model = Bug
class BugAdmin( admin.ModelAdmin ):
fields = ['name', 'slug', 'excerpt', 'summary', 'date_added', 'poster', 'categories', 'status']
prepopulated_fields = { 'slug' : ['name'] }
form = BugForm
I'm aware that I'll have to probably specify exclude = ('date_added',)
and define a def save()
function, but I'm not sure of the specifics needed for this.