models.py 971 Bytes
Newer Older
1
from django.db import models
Daniel W Bond's avatar
Daniel W Bond committed
2
from django.contrib.auth.models import User
3
from autoslug import AutoSlugField
4
5
6
from model_utils.models import TimeStampedModel
from django.core.validators import RegexValidator

7
class Student(TimeStampedModel):
8
    user = models.OneToOneField(User)
9
    # django user includes username, password, first name, and last name
10
11
    rating = models.IntegerField(null=True,default=0)

12
    slug = AutoSlugField(populate_from='user', unique=True)
Daniel W Bond's avatar
Daniel W Bond committed
13
    # populate from user.username, no?
14

15
16
    def __unicode__(self):
        return '%s' % self.user.username
17

18
19
20
class Course(TimeStampedModel):
	name = models.CharField(max_length=255)
	department = models.CharField(max_length=255)
21
22
23
        departmentAbbreviation = models.CharField(max_length=4)
	#number = models.CharField(max_length=255, validators=RegexValidator('[0-9]{3,}'))
	number = models.CharField(max_length=3)
24
25

	def __unicode__(self):
26
		return "%s:%s  %s", self.department, self.number, self.name