
React
16
Вклад в тег
class Book(models.Model):
...
author = models.ForeignKey(Author, related_name="books", on_delete=models.SET_NULL, null=True)
...
def index(request):
context = {}
authors = Author.objects.all()
context['authors'] = authors
return render(request, 'index.html', context)
...
<div>
{% for author in authors %}
<h1>{{ author.first_name }}</h1>
{% for book in author.books.all %}
<h4>{{ book.title }}</h4>
{% empty %}
<p>Похоже, у этого автора нет книг :(</p>
{% endfor %}
{% endfor %}
</div>
...
peerDependencies - это особый тип зависимости, который может возникнуть только в том случае, если вы публикуете свой собственный пакет.
Наличие peerDependencies означает, что вашему пакету нужна такая же зависимость, как и человеку, устанавливающему ваш пакет. Используется для таких пакетов, как react, которые должны иметь единственную копию react-dom, которая также используется человеком, устанавливающим его.
Your project will probably also have static assets that aren’t tied to a particular app. In addition to using a static/ directory inside your apps, you can define a list of directories (STATICFILES_DIRS) in your settings file where Django will also look for static files.