Answer the question
In order to leave comments, you need to log in
True False sorting in Django?
There is a model. I'm trying to get data by type rozdil/true(false)
I registered it in urls but I get an error with int() not string conversion. Code below.
url(r'^rozdil/(?P<is_main>\w+)', 'wiki.views.stats'),
def stats(request,is_main):
stats = Stats.objects.get(main_is=is_main)
context = {'stats':stats}
return render(request,'stats.html',{})
class Rozdil(models.Model):
title = models.CharField(max_length=255,verbose_name="у")
part_of = models.ForeignKey(NamePart,verbose_name="Вн")
is_main = models.BooleanField(default=1,verbose_name="Гол ?")
def get_absolute_url(self):
return "/rozdil/%s/" % self.is_main
def __unicode__(self):
return '%s' % (self.title)
class Stats(models.Model):
name = models.CharField(max_length=170,verbose_name="Голо")
image = models.ImageField(upload_to='media')
robota = RichTextField(verbose_name="Опи")
opus_ustanovku = RichTextField(verbose_name="Опи")
zag_bund = RichTextField(verbose_name="За")
tth = RichTextField(verbose_name="ТТ")
teh_obslug = RichTextField(verbose_name="")
main_is = models.ForeignKey(Rozdil,verbose_name="у")
def get_absolute_url(self):
return "/stats/%i/" % self.id
def __unicode__(self):
return '%s %s' % (self.name, self.main_is)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question