Share Pastebin
Guest
Public paste!

mtigas

By: a guest | Jul 23rd, 2008 | Syntax: Python | Size: 0.88 KB | Hits: 223 | Expires: Never
Copy text to clipboard
  1. #models.py for newforms-admin permissions example
  2. #see http://www.miketigas.com/?p=625
  3. from django.db import models
  4. from django.contrib.auth.models import User
  5.  
  6. class Blog(models.Model):
  7.     name        = models.CharField(max_length=30)
  8.     slug = models.SlugField()
  9.     description = models.TextField()
  10.     # the user that "owns" this blog
  11.     user        = models.ForeignKey(User,blank=True,null=True)
  12.  
  13.     def __unicode__(self):
  14.         return u'%s' % (self.name)
  15.  
  16.     class Meta:
  17.         permissions = (('access_all_blogs','Access to all blogs'),)
  18.  
  19. class BlogPost(models.Model):
  20.     title = models.CharField(max_length=30)
  21.     slug = models.SlugField()
  22.     pubdate = models.DateTimeField()
  23.     post = models.TextField()
  24.  
  25.     def __unicode__(self):
  26.         return u'%s' % (self.title)
  27.  
  28.     class Meta:
  29.         permissions = (('access_all_posts','Access to all posts'),)