This commit is contained in:
Allecks 2022-10-05 17:05:31 +03:00
parent 4439bb6d46
commit 000e45c1de
5 changed files with 20 additions and 7 deletions

View file

@ -1,3 +1,10 @@
from django.contrib import admin from django.contrib import admin
# Register your models here. from .models import Bb
class BbAdmin(admin.ModelAdmin):
list_display = ('title', 'content', 'price', 'published')
list_display_links = ('title', 'content')
search_fields = ('title', 'content', )
admin.site.register(Bb, BbAdmin)

View file

@ -1,8 +1,14 @@
from tabnanny import verbose
from turtle import title from turtle import title
from django.db import models from django.db import models
class Bb (models.Model): class Bb (models.Model):
title = models.CharField(max_length=50) title = models.CharField(max_length=50, verbose_name = 'Товар')
content = models.TextField(null=True, blank=True) content = models.TextField(null=True, blank=True, verbose_name = 'Описание')
price = models.FloatField(null=True, blank=True) price = models.FloatField(null=True, blank=True, verbose_name = 'Цена')
published = models.DateTimeField(auto_now_add=True, db_index=True) published = models.DateTimeField(auto_now_add=True, db_index=True,
verbose_name = 'Опубликованно')
class Meta:
verbose_name_plural = 'Объявления'
verbose_name = 'Объявление'
ordering = ['-published']

View file

@ -3,5 +3,5 @@ from django.shortcuts import render
from .models import Bb from .models import Bb
def index(request): def index(request):
bbs = Bb.objects.order_by('-published') bbs = Bb.objects.all()
return render(request, 'index.html', {'bbs': bbs}) return render(request, 'index.html', {'bbs': bbs})

Binary file not shown.

View file

@ -107,7 +107,7 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/ # https://docs.djangoproject.com/en/4.1/topics/i18n/
LANGUAGE_CODE = 'en-us' LANGUAGE_CODE = 'ru'
TIME_ZONE = 'UTC' TIME_ZONE = 'UTC'