9
9
# - Description
10
10
# - Any other fields you would like to include in car make model
11
11
# - __str__ method to print a car make object
12
+ class CarMake (models .Model ):
13
+ name = models .CharField (null = False , max_length = 30 )
14
+ description = models .CharField (null = False , max_length = 30 )
15
+
16
+ def __str__ (self ):
17
+ return self .name + "" + self .description
12
18
13
19
14
20
# <HINT> Create a Car Model model `class CarModel(models.Model):`:
19
25
# - Year (DateField)
20
26
# - Any other fields you would like to include in car model
21
27
# - __str__ method to print a car make object
28
+ class CarModel (models .Model ):
29
+ TYPES = (
30
+ ("SEDAN" , "Sedan" ), ("SUV" , "SUV" ), ("WAGON" , "Wagon" ), ("LIMOUSINE" , "Limousine" ), ("BATMOBILE" , "Batmobile" )
31
+ )
32
+
33
+ make = models .ForeignKey (CarMake , on_delete = models .CASCADE )
34
+ name = models .CharField (null = False , max_length = 30 )
35
+ c_type = models .CharField (max_length = 30 , choices = TYPES )
36
+ dealer_id = models .IntegerField ()
37
+ year = models .DateField ()
38
+
39
+ def __str__ (self ):
40
+ return "Name: " + self .name + \
41
+ " Make Name: " + self .make .name + \
42
+ " Type: " + self .c_type + \
43
+ " Dealer ID: " + str (self .dealer_id )+ \
44
+ " Year: " + str (self .year )
45
+
22
46
23
47
24
48
# <HINT> Create a plain Python class `CarDealer` to hold dealer data
49
+ class CarDealer :
25
50
51
+ def __init__ (self , address , city , full_name , id , lat , long , short_name , st , zip ):
52
+ # Dealer address
53
+ self .address = address
54
+ # Dealer city
55
+ self .city = city
56
+ # Dealer Full Name
57
+ self .full_name = full_name
58
+ # Dealer id
59
+ self .id = id
60
+ # Location lat
61
+ self .lat = lat
62
+ # Location long
63
+ self .long = long
64
+ # Dealer short name
65
+ self .short_name = short_name
66
+ # Dealer state
67
+ self .st = st
68
+ # Dealer zip
69
+ self .zip = zip
70
+
71
+ def __str__ (self ):
72
+ return "Dealer name: " + self .full_name
26
73
27
74
# <HINT> Create a plain Python class `DealerReview` to hold review data
75
+ class DealerReview :
76
+ def __init__ (self , dealership , name , purchase , review , purchase_date , car_make , car_model , car_year ,sentiment , id ):
77
+ self .dealership = dealership
78
+ self .name = name
79
+ self .purchase = purchase
80
+ self .review = review
81
+ self .purchase_date = purchase_date
82
+ self .car_make = car_make
83
+ self .car_model = car_model
84
+ self .car_year = car_year
85
+ self .sentiment = sentiment #Watson NLU service
86
+ self .id = id
87
+
88
+ def __str__ (self ):
89
+ return "Review: " + self .review + \
90
+ " Sentiment: " + self .sentiment
0 commit comments