skip to Main Content

there is a code #index.html

    <html>
    <head>
        <title></title>
    </head>
    <frameset rows=100% >
        <frameset rows=76%,24% >
            <frameset cols=64%,36% >
                <frame name=reports src="reports.html" >
                <frame name=fg_log src=/****.py >
            </frameset>
            <frameset cols=64%,36% >
                <frame name=fp_log src=/********.py?fp=3&files=on >
                <frame name=ls src=/*******.py >
            </frameset>
        </frameset>
    </frameset>
</html>

at startup, simply by opening index.html through the browser – I see the data of the first frame
enter image description here

but if you start displaying the same index.html through django – I see 404 instead of hello world
enter image description here

and I also see an error in the terminal
enter image description here

I have not found the answer why this is happening and how to solve it, but I need to use frameset

urls.py
from django.urls import path, include

from . import views

app_name = 'core'

urlpatterns = [
    path('', views.index, name='index'),

]

views.py

User = get_user_model()
@login_required
def index(request):
    template = 'core/index.html'
    return render(request, template)

template index.html I have attached above.
There are no problems with launching django

addition to new comments
the problem has not been solved yet

urls.py
from django.urls import path, include
from . import views

app_name = 'core'

urlpatterns = [
    path('', views.index, name='index'),
    path('reports', views.reports, name='reports-name'),
]

views.py
@login_required
def index(request):
    template = 'core/index.html'
    return render(request, template)


def reports(request):
    template = 'core/reports.html'
    return render(request, template)

index.html

<html>
    <head>
        <title></title>
    </head>
    <frameset rows=100% >
        <frameset rows=76%,24% >
            <frameset cols=64%,36% >
                <frame name=reports src="{% url 'core:reports-name' %}">
                <frame name=fg_log src=/cgi-bin/sendjobs.py >
            </frameset>
            <frameset cols=64%,36% >
                <frame name=fp_log src=/cgi-bin/fp_log.py?fp=3&files=on >
                <frame name=ls src=/cgi-bin/ls.py >
            </frameset>
        </frameset>
    </frameset>
</html>

reports.html

hello world

2

Answers


  1. Chosen as BEST ANSWER

    Many thanks to "Razenstein" for the help, to solve the problem it was necessary to disable:

    "settings">"MIDDLEWARE">"# 'django.middleware.clickjacking.XFrameOptionsMiddleware',"
    

  2. There is 2 Scenarios:

    1. reports.html is a dynamic template file to be rendered and served by a django app/view via an url
    2. reports.html is just a static file to be downloaded from server

    add 1) if you want to download reports.html in the frame like any other URL from your app you need to install that path in the urls.py of your app like:

    urls.py
    from django.urls import path, include
    from . import views
    
    app_name = 'core'
    
    urlpatterns = [
        path('', views.index, name='index'),
        path('reports', views.reports, name='reports-name'),
    ]
    

    … create a view:

    def reports(request):
        template = 'core/reports.html'
        return render(request, template)
    

    … and add the url tag to the index.html:

    (this is the django-way of using urls.py as a single point to define url-patterns and reference them by their name anywhere else)

    <frame name=reports src="{% url 'core:reports-name' %}">
    

    with above path, this will translate into:

    <frame name=reports src="reports">
    

    add 2) then it is a static file and should be treated as such like described here in django docs: https://docs.djangoproject.com/en/4.2/howto/static-files/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search