Skip to content

Instantly share code, notes, and snippets.

@mustafaileri
Last active December 5, 2016 21:19
Show Gist options
  • Save mustafaileri/f4953dbba7cdd2847c54725586ee13e5 to your computer and use it in GitHub Desktop.
Save mustafaileri/f4953dbba7cdd2847c54725586ee13e5 to your computer and use it in GitHub Desktop.
drf-haystack-model
class Model(models.Model):
STATUS_CHOICES = (
('active', 'Aktif'),
('passive', 'Pasif'),
('redirected', 'Yönlendirilmiş')
)
TRACTION_CHOICES = (
('front-wheel-drive', 'Önden Çekişli'),
('rear-wheel-drive', 'Arkadan İtişli'),
('four-wheel-drive', 'Dört Çeker')
)
SEGMENT_CHOICES = (
('A', 'A'),
('B', 'B'),
('C', 'C'),
('D', 'D'),
('E', 'E'),
('F', 'F'),
)
car = models.ForeignKey(Car, models.DO_NOTHING, blank=True, null=True, related_name='models')
name = models.CharField(max_length=255)
engine_volume = models.SmallIntegerField()
horse_power = models.SmallIntegerField()
traction = models.CharField(max_length=17, choices=TRACTION_CHOICES)
acceleration = models.IntegerField()
average_fuel_consumption = models.FloatField()
city_fuel_consumption = models.FloatField()
highway_fuel_consumption = models.FloatField()
price = models.IntegerField()
url = models.CharField(max_length=255, blank=True, null=True)
performance_rate = models.SmallIntegerField()
security_rate = models.SmallIntegerField()
economy_rate = models.SmallIntegerField()
smart_rate = models.SmallIntegerField()
series = models.CharField(max_length=255, blank=True, null=True)
status = models.CharField(max_length=13, choices=STATUS_CHOICES)
door_count = models.SmallIntegerField()
max_speed = models.SmallIntegerField()
co2emission = models.FloatField()
torque = models.SmallIntegerField()
cylinders = models.SmallIntegerField()
valves = models.SmallIntegerField()
baggage_volume = models.SmallIntegerField()
tank_volume = models.SmallIntegerField()
seat_count = models.SmallIntegerField()
fuel_type = models.ForeignKey(FuelType, models.DO_NOTHING)
transmission_type = models.ForeignKey(TransmissionType, models.DO_NOTHING)
body_type = models.ForeignKey(BodyType, models.DO_NOTHING)
tax_price = models.ForeignKey(TaxPrice, models.DO_NOTHING)
class Meta:
managed = True
db_table = 'aracmetre_model'
verbose_name = 'Model'
verbose_name_plural = 'Modeller'
def __str__(self):
return self.name
def __unicode__(self):
return unicode(self.name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment