Найти - Пользователи
Полная версия: Django 1.7 как вывести в Аdmin название parent
Начало » Python для новичков » Django 1.7 как вывести в Аdmin название parent
1
and_07
models.py
class Categories(models.Model):
    parent = models.ForeignKey('self', blank=True, null=True, related_name='children_set')
    meta_title = models.TextField(max_length=200,blank=True, null=True)
    meta_description = models.TextField(max_length=255,blank=True, null=True)
    meta_keywords = models.TextField(max_length=255,blank=True, null=True)
    title = models.TextField(max_length=200,blank=True, null=True)
    url = models.TextField(max_length=200,blank=True, null=True)
    name = models.TextField(max_length=100,unique=True,blank=True, null=True)
    visible = models.IntegerField(default=1,null=True) 
    short = models.SmallIntegerField(blank=True, null=True)
    def parent_name(self):
        return self.parent.name
    parent_name.admin_order_field = 'parent__name'
    def __unicode__(self):
        return u'%s' % (self.name)

admin.py
class CategoriesAdmin(admin.ModelAdmin):
    list_display = ('id','name','parent')
    search_fields = ['id','name','parent']
admin.site.register(Categories,CategoriesAdmin)

как вывести в Аdmin название parent сейчас выводится Categories object
sander
class ParentInline(admin.TabularInline):
    model = Parent
    
class CategoriesAdmin(admin.ModelAdmin):
    ........
    inlines = [ParentInline]

то?
and_07
нет не то

даже если изменить
model = Parent
на
model = Categories

все равно не работает

sander
вопрос был четко сформулирован
and_07
о сарказм

а можно пример как нужно было задать вопрос что бы вы поняли
(без скиншота)

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB