Answer the question
In order to leave comments, you need to log in
How to make 20 same model methods in Django?
Hello.
There is
a Model field:
point1 = models.IntegerField(default="0",
help_text="1 - нет (красное), 2 - да (зеленое), 3 - нет (зеленое), 4 - да (красное)",
verbose_name="Защита от спама")
def get_point1(self):
if self.point1 == 1:
return '<span class="chart_font_1"><i class="fa fa-times" aria-hidden="true"></i></span>'
elif self.point1 == 2:
return '<span class="chart_font_2"><i class="fa fa-check" aria-hidden="true"></i></span>'
elif self.point1 == 3:
return '<span class="chart_font_3"><i class="fa fa-times" aria-hidden="true"></i></span>'
elif self.point1 == 4:
return '<span class="chart_font_4"><i class="fa fa-check" aria-hidden="true"></i></span>'
else:
return '<span class="chart_font_1"><i class="fa fa-times" aria-hidden="true"></i></span>'
Answer the question
In order to leave comments, you need to log in
You can INSERT multiple records at the same time:
dev.mysql.com/doc/refman/5.5/en/insert.html
Post::insert(array(
array(
'title' => 'Laravel - замечателен!',
'author' => 'Джейсон',
'body' => 'Laravel очень удобен - используйте его, если вы ещё этого не делаете!'
),
array(
'title' => 'Laravel - простая работа с БД!',
'author' => 'Джейсон',
'body' => 'Нет ничего проще, чем работать с базами данных с помощью Eloquent.'
)
));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question