Permalink
Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign up
Fetching contributors…
Cannot retrieve contributors at this time.
Cannot retrieve contributors at this time
| from django.db import models | |
| from django.contrib.auth.models import User | |
| class Category(models.Model): | |
| name = models.CharField(max_length = 128, unique = True) | |
| views = models.IntegerField(default = 0) | |
| likes = models.IntegerField(default = 0) | |
| def __unicode__(self): | |
| return self.name | |
| class Page(models.Model): | |
| category = models.ForeignKey(Category) | |
| title = models.CharField(max_length = 128) | |
| url = models.URLField(unique = True) | |
| views = models.IntegerField(default = 0) | |
| def __unicode__(self): | |
| return self.title | |
| class UserProfile(models.Model): | |
| # This line is required. Links UserProfile to a User model instance. | |
| user = models.OneToOneField(User) | |
| # The additional attribute we wish to include. | |
| website = models.URLField(blank = True) | |
| picture = models.ImageField(upload_to = 'profile_images', blank = True) | |
| # Override the __unicode__() method to return out something meaningful! | |
| def __unicode__(self): | |
| return self.user.username |