A
A
Alexander2016-04-04 08:41:51
Django
Alexander, 2016-04-04 08:41:51

Django returning an object from a brace?

models.py

class New(models.Model):
     ...
    category_id = models.ForeignKey(TourCategory, verbose_name="Категория тура", related_name="tour_category")

Here's what's in the admin:
<select id="id_category_id" name="category_id">
<option value="" selected="selected">---------</option>
<option value="1">TourCategory object</option>
<option value="2">TourCategory object</option>
<option value="3">TourCategory object</option>
</select>

I tried like this but it didn't work:
list_select_related = ('tour_category', 'name')

    def get_list_select_related(self, request):
        return self.list_select_related

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2016-04-04
@kentuck1213

class TourCategory(models.Model):
    name = models.CharField(max_length=200, verbose_name="Имя")

    def __str__(self):
        return self.name

C
Cyber_bober, 2016-04-04
@Cyber_bober

is this output to custom admin panel or native django admin panel?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question