Created
February 2, 2015 23:02
-
-
Save kennethlove/3c32b150c4e9de8da0e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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