Login

Snippets by ashcrow

Snippet List

UnicodeReprMixIn

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__
Read More

Full Featured Gravatar Tag

Simply returns a created gravatar url based on input. Creates the url utilizing the full gravatar url inputs as defined at http://en.gravatar.com/site/implement/url.

  • tag
  • simple_tag
  • avatar
  • gravatar
Read More

Bind Administration

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')

  • admin
  • 1.0
  • modeladmin
Read More

ashcrow has posted 3 snippets.