Answer the question
In order to leave comments, you need to log in
How to make a separate Django page resizable through the admin?
Dear experts, please tell me how to make it possible to change the "About the company" page through the django admin panel without going into the html code of the page in the future, the model created
class About(models.Model):
title = models.CharField(max_length=255, verbose_name="Каталог")
slug = models.SlugField(max_length=255, verbose_name="URL", unique=True)
text = models.TextField(verbose_name='О компании', blank=True)
image = models.ImageField(upload_to='image/%Y/%m/', verbose_name='Картинка', blank=True)
def __str__(self):
return self.title
def get_absolute_url(self):
return reverse('catalog', kwargs={"slug": self.slug})
class Meta:
verbose_name = 'О компании'
verbose_name_plural = 'О компании '
class AboutBy(DetailView):
model = About
template_name = 'about.html'
context_object_name = 'about'
def get_context_data(self, *, object_list=None, **kwargs):
context = super(AboutBy, self).get_context_data(**kwargs)
context['title'] = 'О компании'
return context
path('<str:slug>/', AboutBy.as_view(), name='about'),
Answer the question
In order to leave comments, you need to log in
and through the standard django-admin tools, django- admin
is not suitable
@admin.register(About)
class AboutAdmin(admin.ModelAdmin):
....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question