Когда я отображаю сайт в конце каждой формы, появляется строка "Human ptr:" ... как я могу удалить его?(Человек - это класс, из которого Происходит игрок)
У меня есть форма, созданная с помощью modelformset_factory, сгенерированной так:
team_area.html
{% extends 'base_layout.html' %}
{% block content %}
<h1>Area Squadra</h1>
<form method="post" action="">
{% csrf_token %}
{{ player_formset.management_form }}
{% for player_form in player_formset %}
{% for field in player_form %}
{{ field.label_tag }} {{ field }}
{% endfor %}
<br>
{% endfor %}
<input type="submit" value="Aggiorna">
</form>
{% endblock %}
И представление управляется:
views.py
from django.shortcuts import render, redirect
from skeleton.models import Player
from django.contrib.auth.decorators import login_required
from .forms import PlayerForm
from django.forms import modelformset_factory
from django.http import HttpResponseNotFound
# Create your views here.
@login_required(login_url="/accounts/login/")
def team_area(request):
if request.user.team != None:
PlayerFormSet = modelformset_factory(Player, form=PlayerForm, extra=1, can_delete=True,)
if request.method == "POST":
player_formset = PlayerFormSet(
request.POST,
request.FILES,
queryset=Player.objects.all().filter(team=request.user.team),)
for player_form in player_formset:
if player_form.is_valid():
player = player_form.save(commit=False)
player.team = request.user.team
#if player.first_name != '' and player.last_name != '':
# player.save()
if player_formset.is_valid():
player_formset.save()
return redirect('team_area:home')
else:
player_formset = PlayerFormSet(queryset=Player.objects.all().filter(team=request.user.team))
return render(request, 'team_area/team_area.html', {'player_formset': player_formset})
else:
return render(request, 'team_area/empty_page.html')
base_layout.html
{% load static from staticfiles %}
<!DOCTYPE html>
<html lang="it" dir="ltr">
<head>
<meta charset="utf-8">
<title>ioniCup</title>
</head>
<body>
<header>
{% block header %}
<ul>
<li><a href="{% url 'home' %}">Home</a></li>
<li><a href="{% url 'team_area:home' %}">Area Squadre</a></li>
<li><a href="{% url 'admin:index' %}">Admin</a></li>
{% if user.is_authenticated %}
<li>
<form class="logout_link" action="{% url 'accounts:logout' %}" method="post">
{% csrf_token %}
<button type="submit">Logout</button>
</form>
</li>
{% else %}
<li><a href="{% url 'accounts:signup' %}">Signup</a></li>
<li><a href="{% url 'accounts:login' %}">Login</a></li>
{% endif %}
</ul>
{% endblock %}
</header>
<div class="content">
{% block content %}
<h1>Home</h1>
{% endblock %}
</div>
<footer>
{% block footer %}
<h4>COPYRIGHT © 2018 IONICUP. TUTTI I DIRITTI RISERVATI.</h4>
{% endblock %}
</footer>
</body>
</html>
Я ожидаю удаленияПтр человека: возможно без CSS или JavaScript