def attachment_upload_to(instance, filename):
 now = datetime.now()
 return ('attachments/%(date)s/%(id)s/%(md5)s/%(filename)s' % {'date': now.strftime('%Y/%m/%d'), 'id': instance.attachment.id, 'md5': hashlib.md5(str(now)).hexdigest(), 'filename': filename})

def attachment_upload_to ( instance , filename ) : now = datetime . now ( ) return ( 'attachments/%(date)s/%(id)s/%(md5)s/%(filename)s' % { 'date' : now . strftime ( '%Y/%m/%d' ) , 'id' : instance . attachment . id , 'md5' : hashlib . md5 ( str ( now ) ) . hexdigest ( ) , 'filename' : filename } )
generate a path to store a file attachment .