Answer the question
In order to leave comments, you need to log in
How to display information from sql on a website page?
No matter how I try to display information on the page, nothing comes out. I tried with and without classes, and according to the off-line article and YouTube, a nightmare, help me out. There are no errors, just the page is empty, in the code on the site the body is empty. Migrations were carried out, in the admin panel I created a couple of forms, but it does not display ...
models.py
from django.db import models
from datetime import date
class Di(models.Model):
"""Директора и заместители"""
name = models.CharField("Имя", max_length=100)
image = models.ImageField("Изображение", upload_to="dir/")
def __str__(self):
return self.name
class Meta:
verbose_name = "Директора и заместители"
verbose_name_plural = "Директора и заместителя"
class Corporation(models.Model):
"""Корпорация"""
title = models.CharField("Название", max_length=50)
tagline = models.CharField("Короткое название", max_length=5, default='', help_text="указывать как в eve")
logo = models.ImageField("Логотип", upload_to="movies/")
country = models.CharField("Страна", max_length=30)
directors = models.ManyToManyField(Di, verbose_name="Директор", related_name="corp_director")
deputy = models.ManyToManyField(Di, verbose_name="Заместители", related_name="corp_deputy")
world_premiere = models.DateField("Дата присоединения", default=date.today)
act = models.CharField("Акции", max_length=30, help_text="указывать остаток")
url = models.SlugField(max_length=130, unique=True)
def __str__(self):
return self.title
class RatingStar(models.Model):
"""Рейтинг Zkillboard"""
value = models.SmallIntegerField("Значение", default=0)
def __str__(self):
return f'{self.value}'
class Meta:
verbose_name = "Рейтинг Zkillboard"
verbose_name_plural = "Рейтинги Zkillboard"
ordering = ["-value"]
class Rating(models.Model):
"""Рейтинг"""
ip = models.CharField("IP адрес", max_length=15)
star = models.ForeignKey(RatingStar, on_delete=models.CASCADE, verbose_name="Рейтинг")
corporation = models.ForeignKey(Corporation, on_delete=models.CASCADE, verbose_name="Корпорация")
def __str__(self):
return f"{self.star} - {self.corporation}"
class Meta:
verbose_name = "Рейтинг"
verbose_name_plural = "Рейтинги"
from django.shortcuts import render
from django.views.generic.base import View
from .models import Corporation
def index(request):
return render(request, 'main/index.html')
def alliance(request):
return render(request, 'main/alliance.html')
def control(request):
return render(request, 'main/control.html')
def promotions(request):
return render(request, 'main/promotion.html')
def vacancies(request):
return render(request, 'main/vacancies.html')
def rent(request):
return render(request, 'main/rent.html')
def inst(request):
return render(request, 'main/inst.html')
class CorpView(View):
def get(self, request):
corp = Corporation.objects.all()
return render(request, 'main/alliance.html', {"corp": corp})
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='home'),
path('alliance', views.CorpView.as_view(), name='alliance'),
path('control', views.control, name='control'),
path('promotions', views.promotions, name='promotions'),
path('vacancies', views.vacancies, name='vacancies'),
path('rent', views.rent, name='rent'),
path('inst', views.inst, name='inst'),
]
<!doctype html>
<html lang="ru" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>EvE-FoT</title>
{% load static %}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">
<link rel="stylesheet" href="{% static 'main/css/main.css' %}">
</head>
<body>
<header>
<img src="{% static 'main/img/logo1.png' %}" alt="Лого">
<span class="logo">Federation of Time</span>
<ul>
<a href="{% url 'home' %}"><li>Главная</li></a>
<a href="{% url 'alliance' %}"><li>Альянс</li></a>
<a href="{% url 'control' %}"><li>Контакты</li></a>
<a href="{% url 'promotions' %}"><li>Акции</li></a>
<a href="{% url 'vacancies' %}"><li>Вакансии</li></a>
<a href="{% url 'rent' %}"><li>Аренда</li></a>
<a href="{% url 'inst' %}"><li>Инструменты</li></a>
<a href="https://zkillboard.com/corporation/98660988/"><li><i class="fas fa-meteor"></i>Zkillboard</li></a>
<a href="http://62.109.0.32/"><li><i class="fas fa-user-secret"></i>SEAT</li></a>
<a href="https://www.youtube.com/channel/UCfspMBqcqaK2DmftPfN4vDw"><li><i class="fab fa-youtube"></i>YouTube</li></a>
</ul>
</header>
<main>
{% for corporation in corp %}
{{ title.tagline }}
{% endfor %}
</main>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Oh sure.
$('.slider-for').slick({
slidesToShow: 1,
slidesToScroll: 1,
arrows: false,
fade: true,
asNavFor: '.slider-nav'
});
$('.slider-nav').slick({
slidesToShow: 3,
slidesToScroll: 1,
asNavFor: '.slider-for',
dots: true,
centerMode: true,
focusOnSelect: true
});
{% for corporation in corp %}
{{ title.tagline }}
{% endfor %}
{{corporation.title}} . {{corporation.tagline}}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question