Используйте абсолютное позиционирование и z-index для создания липкого нижнего колонтитула с любым разрешением, используя следующие шаги:
position: absolute; bottom: 0;
и желаемой высотой div
, который обертывает содержимое тела с помощью position: relative; min-height: 100%;
div
, равное высоте и дополнению нижнего колонтитула z-index
больше, чем контейнер div
, если нижний колонтитул обрезается Вот пример:
<!doctype html>
<html>
<head>
<title>Sticky Footer</title>
<meta charset="utf-8">
<style>
.wrapper { position: relative; min-height: 100%; }
.footer { position: absolute; bottom:0; width: 100%; height: 200px; padding-top: 100px; background-color: gray; }
.column { height: 2000px; padding-bottom: 300px; background-color: green; }
/* Set the `html`, `body`, and container `div` to `height: 100%` for IE6 */
</style>
</head>
<body>
<div class="wrapper">
<div class="column">
<span>hello</span>
</div>
<div class="footer">
<p>This is a test. This is only a test...</p>
</div>
</div>
</body>
</html>
tech_lead = models.ForeignKey(User, related_name='tech_lead')
нарушает целостность, потому что ваша база данных уже заполнена Application
экземплярами. Если вы хотите добавить ненулевой FK в вашу схему, вам следует указать значение по умолчанию. В противном случае, если вы не можете предоставить значение по умолчанию, вам следует рассмотреть возможность разрешения tech_lead
быть НЕДЕЙСТВИТЕЛЬНЫМ, т.е. заполните поле желаемыми значениями:
from django.db import migrations
def populate_tech_lead(apps, schema_editor):
Application = apps.get_model('yourappname', 'Application')
for application in Application.objects.all():
application.tech_lead = application.assessment_owner
application.save()
class Migration(migrations.Migration):
dependencies = [
('yourappname', '0001_initial'),
]
operations = [
migrations.RunPython(populate_tech_lead),
]
и затем удалите null=True
из поля:
tech_lead = models.ForeignKey(User, related_name='tech_lead')
Шаг 1. Добавьте null=True
в поле tech_lead как
class Application(models.Model):
assessment_owner = models.ForeignKey(User, related_name='assessment_owner')
creator = models.ForeignKey(User, related_name='creator')
tech_lead = models.ForeignKey(User, related_name='tech_lead', null=True)
Шаг 2. Создайте файл миграции с помощью python manage.py makemigrations
[ 1116]
Шаг 3. перенести db python manage.py migrate
Шаг 4. открыть оболочку django, [1118 ] python manage.py shell
Шаг 5. Запустите следующий скрипт
from your_app.models import Application
from django.db.models.expressions import F
Application.objects.filter(tech_lead__isnull=True).update(tech_lead=F('assessment_owner'))