Login

Snippets by depaolim

Snippet List

Automatic Folder FileField

Your MEDIA_ROOT directories are a mess? FileField save on "upload_to" directories with old/strange/temporary names decided "on the fly" and never fixed down? SmartFolderFileField is the solution! "upload_to" directory depends only on: app, model and field names. No mess, no ambiguities Obviously, in case you need a real callable for a dynamic directory name: please use it! and leave apart FixedFolderFileField Sample: from django.db import models from utilities_app.models import SmartFolderFileField class SampleModel(models.Model): sample_char_field = models.CharField(max_length=50) sample_file_field = SmartFolderFileField()

  • upload_to
  • FileField
Read More

model save memos

A simple example to show how to manage an history of memo-on-save. Each time the user saves the model, he must provide a memo message. The full memos history is shown as a read-only tabular-inline. For each memo, user and date are also registered ([Django-Admin-Collapsed-Inlines](https://github.com/virajkanwade/Django-Admin-Collapsed-Inlines) could be usefull)

  • admin
Read More

depaolim has posted 3 snippets.