iframe показывает, что не может подключиться. Я пробовал использовать для представления декоратор @xframe_options_exempt
по умолчанию, а также django -csp @csp_exempt
, но безрезультатно.
Приведены следующие ошибки консоли:
Refused to display 'http://localhost:8000/new_pull/' in a frame because it set 'X-Frame-Options' to 'deny'.
и Failed to load resource: the server responded with a status of 404 (Not Found)
вид
@csp_exempt
@login_required
def new_pull(request):
"""Create a new pull request"""
if request.method != 'POST':
# No data submitted; create a blank form
form = PullForm()
else:
# POST data submitted; process data
form = PullForm(data=request.POST)
if form.is_valid():
new_pull = form.save(commit=False)
new_pull.owner = request.user
new_pull.save()
# Display a blank or invalid form.
context = {'form': form}
return render(request, 'learning_logs/new_pull.html', context)
base. html
{% if user.is_authenticated %}
<br>
<iframe src="{% url 'learning_logs:new_pull' %}" title="Pull request Iframe"></iframe>
<iframe src="learning_logs/new_pull.html" title="Pull request Iframe"></iframe>
{% endif %}
new_pull. html
<div class="pull container text-center border-top mt-5">
<h5 class="mt-2">Pull request</h5>
<p>New pull request:</p>
<form action="{% url 'learning_logs:new_pull' %}" method='post'>
{% csrf_token %}
{% bootstrap_form form %}
{% buttons %}
<button name="submit" class="btn btn-green pl-2 pr-2">
<i class="fas fa-plus-circle"></i>
Create pull
</button>
{% endbuttons %}
<input type="hidden" name="next"
value="{% url 'learning_logs:bug_tracker' %}" />
</form>
</div>