2
At Django I’m developing a Library project! (I’m Beginner at Django, I’ve never worked with web development)
Summarizing I have in the file models.py a model Library and a model Book, in the model Book there is a Library Foreignkey.
The entire project is on Github, there can be viewed models.py, Forms.py and views.py
Marked red in the image, this error generated on my page.
Code of My template:
{% extends 'base.html' %}
{% load staticfiles %}
{% block title %}Chameleon | Cadastro de Livro{% endblock %}
{% block Estilo %}
<link href="{% static 'css/cadastros.css' %}" rel="stylesheet">
{% endblock %}
{% block Corpo %}
<div class="container">
<form class="form-signin" role="form" action="." method="post"> {% csrf_token %}
<h2 class="form-signin-heading">Cadastro</h2>
<input type="text" class="form-control" id="codigo" name= "codigo" placeholder="Codigo" required autofocus>
<input type="text" class="form-control" id="titulo" name= "titulo" placeholder="Titulo" required>
<input type="text" class="form-control" id="autor" name= "autor" placeholder="Autor" required>
<input type="text" class="form-control" id="editora" name= "editora" placeholder="Editora" required>
<input type="text" class="form-control" id="genero" name= "genero" placeholder="Genero" required>
<input type="text" class="form-control" id="publicacao" name= "publicacao" placeholder="Ano: 0000" required>
<textarea id="sinopse" name="sinopse" placeholder="Sinopse" rows = 10 cols = 63 required></textarea><hr>
<select id="biblioteca" name="biblioteca">
<option value="" selected="selected"> ------------- </option>
<option value="{{ form.biblioteca }}" selected="selected"></option>
</select><hr>
<br><p><button class="btn btn-lg btn-primary btn-block" type="submit">Salvar</button></p>
</form>
</div>
{% endblock %}
{% block JScript %}
{% endblock %}
When I display the page source code the tag part <select>
this way:
<!-- Inicio Select -->
<select id="id_biblioteca" name="biblioteca">
<option value="" selected="selected"> ------------- </option>
<option value= "<select id="id_biblioteca" name="biblioteca"><option value="" selected="selected">---------</option><option value="1">Chameleon</option></select>" selected="selected"></option>
</select><hr>
<!-- Fim Select -->
It means that a Library can have several books!
– water