Don't like ads? PRO users don't see any ads ;-)
Guest

mtigas

By: a guest on Jul 23rd, 2008  |  syntax: Python  |  size: 0.88 KB  |  hits: 237  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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'),)