Render markdown to a separate model field
This function, meant to be used with the pre_save signal, will convert any markdown from a text field to it's corresponding html field.
- markdown
This function, meant to be used with the pre_save signal, will convert any markdown from a text field to it's corresponding html field.
This snippit is meant to be used with the pre_delete signal to delete any files associated with a model instance before the instance is deleted. It will search the model instance for fields that are subclasses of FieldFile, and then delete the corresponding files. As such, it will work with any model field that is a subclass of FileField.
This snippit can be used to generate unique file names for uploads. `upload_to` allows a callable, but only provides two arguments: `instance` and `filename`. In order to prevent dumping all of the files for a model into one directory, this utilizes the `partial` decorator from `functools`, which essentially allows adding an extra argument to the function. The returned path will be of the form: `[model name]/[field_name]/[random hash].[filename extension]`
mindcruzer has posted 3 snippets.