I am trying to use @login_required to only allow login in users to access various views.
My code for the page login directs the user to after logging in is:
@login_required
def wheel(request):
return render(request, "ISO22301/wheel.html",)
If I the select a link to navigate to another page I get:
Internal Server Error: /ISO22301/introduction/
Traceback (most recent call last):
File "/Users/beyondscorecard/Documents/GitHub/Resilience/.venv/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/beyondscorecard/Documents/GitHub/Resilience/.venv/lib/python3.12/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/beyondscorecard/Documents/GitHub/Resilience/.venv/lib/python3.12/site-packages/django/contrib/auth/decorators.py", line 60, in _view_wrapper
return view_func(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/beyondscorecard/Documents/GitHub/Resilience/ISO22301/views.py", line 24, in introduction
create_context=createheader(0) #pass starting values to use to extract desired text, get tuple
^^^^^^^^^^^^^^^
File "/Users/beyondscorecard/Documents/GitHub/Resilience/.venv/lib/python3.12/site-packages/django/contrib/auth/decorators.py", line 57, in _view_wrapper
test_pass = test_func(request.user)
^^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'user'
[28/Sep/2024 20:09:30] "GET /ISO22301/introduction/ HTTP/1.1" 500 73338
The wheel template code (png code deleted):
{% load static %}
<!DOCTYPE html>
<html lang = 'en'>
<style>
#path_rm {
fill: red;
opacity: .5;
</style>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<head>
<link rel='stylesheet' href='{% static 'css/styles.css' %}'>
</head>
<h1>Resilience</h1>
<body>
<!--
<img src='{% static 'images/ISO_Map2.svg' %}' alt='ISO Map' usemap='#ISO'>
</map> -->
<div class='containervert' style='top: 5%;'>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated by Pixelmator Pro 3.6.9 -->
<svg width="720" height="688" viewBox="0 0 720 688" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<path id="path_center" fill="#027aff" stroke="none" opacity="0" d="M 457 331.5 C 457 278.204529 413.795502 235 360.500092 235 C 307.204498 235 264 278.204529 264 331.5 C 264 384.795471 307.204498 428 360.500092 428 C 413.795502 428 457 384.795471 457 331.5 Z"/>
<path id="path_cm" fill="#027aff" stroke="none" opacity="0" d="M 708.919983 329.78241 C 708.919983 310.452454 693.249939 294.78241 673.920044 294.78241 C 654.590027 294.78241 638.919983 310.452454 638.919983 329.78241 C 638.919983 349.112366 654.590027 364.78241 673.920044 364.78241 C 693.249939 364.78241 708.919983 349.112366 708.919983 329.78241 Z"/>
<path id="path_rm" fill="#027aff" stroke="none" opacity="0" d="M 676.919983 195.78241 C 676.919983 176.452454 661.249939 160.78241 641.920044 160.78241 C 622.590027 160.78241 606.919983 176.452454 606.919983 195.78241 C 606.919983 215.112366 622.590027 230.78241 641.920044 230.78241 C 661.249939 230.78241 676.919983 215.112366 676.919983 195.78241 Z"/>
<path id="path_is" fill="#027aff" stroke="none" opacity="0" d="M 532.919983 52.78241 C 532.919983 33.452454 517.249939 17.78241 497.920013 17.78241 C 478.589996 17.78241 462.919983 33.452454 462.919983 52.78241 C 462.919983 72.112366 478.589996 87.78241 497.920013 87.78241 C 517.249939 87.78241 532.919983 72.112366 532.919983 52.78241 Z"/>
<a href='{% url 'introduction' %}'>
<path id="path_bc" fill="#027aff" stroke="none" opacity="0" d="M 210.919983 80.78241 C 210.919983 61.452454 195.249954 45.78241 175.920013 45.78241 C 156.590012 45.78241 140.919983 61.452454 140.919983 80.78241 C 140.919983 100.112366 156.590012 115.78241 175.920013 115.78241 C 195.249954 115.78241 210.919983 100.112366 210.919983 80.78241 Z"/>
</a>
<path id="path_hr" fill="#027aff" stroke="none" opacity="0" d="M 82.919983 332.78241 C 82.919983 313.452454 67.249954 297.78241 47.920013 297.78241 C 28.59001 297.78241 12.919983 313.452454 12.919983 332.78241 C 12.919983 352.112366 28.59001 367.78241 47.920013 367.78241 C 67.249954 367.78241 82.919983 352.112366 82.919983 332.78241 Z"/>
<path id="path_ict" fill="#027aff" stroke="none" opacity="0" d="M 110.919983 467.78241 C 110.919983 448.452454 95.249954 432.78241 75.920013 432.78241 C 56.590012 432.78241 40.919983 448.452454 40.919983 467.78241 C 40.919983 487.112366 56.590012 502.78241 75.920013 502.78241 C 95.249954 502.78241 110.919983 487.112366 110.919983 467.78241 Z"/>
<path id="path_sc" fill="#027aff" stroke="none" opacity="0" d="M 195.919983 568.78241 C 195.919983 549.452454 180.249954 533.78241 160.920013 533.78241 C 141.590012 533.78241 125.919983 549.452454 125.919983 568.78241 C 125.919983 588.112366 141.590012 603.78241 160.920013 603.78241 C 180.249954 603.78241 195.919983 588.112366 195.919983 568.78241 Z"/>
<path id="path_fa" fill="#027aff" stroke="none" opacity="0" d="M 312.919983 628.78241 C 312.919983 609.452454 297.249969 593.78241 277.920013 593.78241 C 258.589996 593.78241 242.919983 609.452454 242.919983 628.78241 C 242.919983 648.112366 258.589996 663.78241 277.920013 663.78241 C 297.249969 663.78241 312.919983 648.112366 312.919983 628.78241 Z"/>
<path id="path_env" fill="#027aff" stroke="none" opacity="0" d="M 473.919983 635.78241 C 473.919983 616.452454 458.249969 600.78241 438.920013 600.78241 C 419.589996 600.78241 403.919983 616.452454 403.919983 635.78241 C 403.919983 655.112366 419.589996 670.78241 438.920013 670.78241 C 458.249969 670.78241 473.919983 655.112366 473.919983 635.78241 Z"/>
<path id="path_hs" fill="#027aff" stroke="none" opacity="0" d="M 593.919983 574.78241 C 593.919983 555.452454 578.249939 539.78241 558.920044 539.78241 C 539.590027 539.78241 523.919983 555.452454 523.919983 574.78241 C 523.919983 594.112366 539.590027 609.78241 558.920044 609.78241 C 578.249939 609.78241 593.919983 594.112366 593.919983 574.78241 Z"/>
<path id="path_em" fill="#027aff" stroke="none" opacity="0" d="M 676.919983 467.78241 C 676.919983 448.452454 661.249939 432.78241 641.920044 432.78241 C 622.590027 432.78241 606.919983 448.452454 606.919983 467.78241 C 606.919983 487.112366 622.590027 502.78241 641.920044 502.78241 C 661.249939 502.78241 676.919983 487.112366 676.919983 467.78241 Z"/>
</svg>
</div>
</body>
</html>