from django.db import models
class Bb(models.Model):
title = models.CharField(max_length=50, verbose_name='Товар')
content = models.TextField(null=True, blank=True, verbose_name='Описание')
price = models.FloatField(null=True, blank=True, verbose_name='Цена')
published = models.DateTimeField(auto_now_add=True, db_index=True, verbose_name='Опубликовано')
class Meta:
verbose_name_plural = 'Объявления'
verbose_name = 'Объявление'
ordering = ['-published']
from .models import Bb
from django.shortcuts import render
def index(request):
bbs = Bb.objects.all()
return render(request, "btest/index.html", {'bbs': bbs})
from django.contrib import admin
from .models import Bb
class BbAdmin(admin.ModelAdmin):
list_display = ('title', 'content', 'price', 'published')
list_display_links = ('title', 'content')
search_fields = ('title', 'content', 'price', 'published')
admin.site.register(Bb, BbAdmin)