Snippet List
Add's updated and created fields to a model if mixed in.
Example that uses the name as the representation:
class Company(models.Model, UnicodeReprMixIn):
"""
A representation of a comic book company.
"""
name = models.CharField(max_length=255)
slug = models.SlugField()
logo = models.ImageField(upload_to=os.path.join('upload', 'company_logos'))
url = models.URLField(verify_exists=True)
_unicode = "name"
- model
- unicode
- orm
- mixin
- __unicode__
Binds $Model to $ModelAdmin without having to specify each binding manually. The ModelAdmins **must** have the same name as the model (as well as same case) with Admin appended.
Example:
from django.db import models
class SomeModel(models.Model):
name = models.CharField(max_length=255)
class AnotherModel(models.Model):
name = models.CharField(max_length=255)
# bind administration
bind_administration('myproject.myapp.models', 'myproject.myapp.admin')
ashcrow has posted 3 snippets.