Login

Tag "automatic"

Snippet List

Model Mixin to Save Only Changed Fields

**[Improved and Released as Save The Change.](https://github.com/karanlyons/django-save-the-change)** Django 1.5 added the `update_fields` `kwarg` to `Model.save()`, which allows the developer to specify that only certain fields should actually be committed to the database. However, Django provides no way to automatically commit only changed fields if they're not specified. This mixin keeps track of which fields have changed from their value in the database, and automatically applies `update_fields` to update only those fields.

  • model
  • save
  • mixin
  • class
  • automatic
  • update_fields
Read More

Automatically generate admin

A management command to automatically generate a fully specified admin for the models in a specific app. It automatically generates raw_id_fields, search_fields, list_filter and more. It bases this on date fields, fields named as "name" or slug. Usage: ./manage admin_autogen <model>

  • django
  • scaffold
  • auto
  • django-admin
  • automatic
  • generation
  • generate
Read More

Automatically set up a project

This is a script to automatically set up a django project It takes only one argument for the project name This works for Django 1.4 It will create the following directory structure: /project /server (app name) /media: /html /css /js /img

  • automatic
  • createproject
Read More

Automatic slug generation signal

A pre_save signal that will automatically generate a slug for your model based on the "title" attribute, and will store the new slug in the "slug" attribute. USAGE: from django.db.models.signals import pre_save from YOURPACKAGE import slug_generator pre_save.connect(slug_generator, sender=YOURMODEL)

  • slug
  • slugify
  • automatic
Read More

Auto-create Django admin user during syncdb

This avoids the frustrating step of having to set up a new admin user every time you re-initialize your database. Put this in any `models` module. In this example I use `common.models`. Adapted from http://stackoverflow.com/questions/1466827/

  • django
  • admin
  • user
  • syncdb
  • manage
  • automatic
  • adminuser
  • admin-user
Read More

5 snippets posted so far.