Skip to content

Instantly share code, notes, and snippets.

@kennethlove
Created February 2, 2015 23:02
Show Gist options
  • Save kennethlove/3c32b150c4e9de8da0e2 to your computer and use it in GitHub Desktop.
Save kennethlove/3c32b150c4e9de8da0e2 to your computer and use it in GitHub Desktop.
class Car(Model):
make = CharField()
model = CharField()
year = IntegerField()
@classmethod
def add_car(cls, make, model, year):
try:
cls.create(make=make, model=model, year=year)
except IntegrityError:
raise ValueError("That car already exists")
class Car(Model):
make = CharField()
model = CharField()
year = IntegerField()
def add_car(make, model, year):
try:
Car.create(make=make, model=model, year=year)
except IntegrityError:
raise ValueError("That car already exists")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment