models.py 893 B

12345678910111213141516171819202122232425262728
  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. def __unicode__(self):
  15. return unicode(self.user)
  16. class Snippet(models.Model):
  17. created = models.DateTimeField(auto_now_add=True)
  18. title = models.CharField(max_length=100, blank=True, default='')
  19. code = models.TextField()
  20. linenos = models.BooleanField(default=False)
  21. class Meta:
  22. ordering = ('created',)