models.py 831 B

12345678910111213141516171819202122232425
  1. from django.db import models
  2. from django.contrib.auth.models import User
  3. # Create your models here.
  4. class UserProfile(models.Model):
  5. # This line is required. Links UserProfile to a User model instance.
  6. user = models.OneToOneField(User)
  7. # Override the __unicode__() method to return out something meaningful!
  8. def __unicode__(self):
  9. return self.user.username
  10. class Profile(models.Model):
  11. user = models.ForeignKey(User)
  12. oauth_token = models.CharField(max_length=200)
  13. oauth_secret = models.CharField(max_length=200)
  14. class Snippet(models.Model):
  15. created = models.DateTimeField(auto_now_add=True)
  16. title = models.CharField(max_length=100, blank=True, default='')
  17. code = models.TextField()
  18. linenos = models.BooleanField(default=False)
  19. class Meta:
  20. ordering = ('created',)