gpt4 book ai didi

it shows OS error if i try to open the links(如果我尝试打开链接,它会显示操作系统错误)

转载 作者:bug小助手 更新时间:2023-10-26 19:38:14 24 4
gpt4 key购买 nike



i am making a webpage which looks like this using django :

我正在用Django制作一个网页,看起来像这样:


the webpage

该网页


while opening the links , it shows OS error :
[Errno 22] Invalid argument: 'C:\Users\Lenovo\Desktop\django projects\env\Lib\site-packages\django\contrib\admin\templates\home\ran_num_gen.html'

打开链接时,它显示操作系统错误:[Errno 22]无效参数:‘C:\USERS\Lenovo\Desktop\Django projects\env\Lib\site-packages\django\contrib\admin\templates\home\ran_num_gen.html’


i am unable to find out the cause of it. help me understand more about it . following is the relevant code and screenshots :

我找不到原因,帮我了解一下。以下是相关代码和截图:


DIRECTORIES

目录


views.py :

Views.py:


from django.shortcuts import render
from django.template.context import Context
# Create your views here.

def home(request):

return render(request , 'home\home.html' )

def num_guess_game(request):

return render (request ,'home\num_guess_game.html')

def ran_num_gen(request):

return render (request ,'home\ran_num_gen.html')

def ran_pwd_gen(request):

return render (request ,'home\ran_pwd_gen.html')



urls.py :

Urls.py:


"""
URL configuration for core project.

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from home.views import *

urlpatterns = [
path('admin/', admin.site.urls),
path('', home ,name='home'),
path('ran_num_gen/', ran_num_gen , name='ran_num_gen' ),
path('ran_pwd_gen/', ran_pwd_gen ,name='ran_pwd_gen' ),
path('num_guess_game/', num_guess_game , name='num_guess_game' ),


]



home.html :

Home.html:


{% extends 'home\base.html' %}

{% block title %}Welcome to homepage{% endblock title %}

{% block content %}

<h1>welcome to ALL ABOUT RANDOM</h1>
<p>i made this site to learn more about django</p>
you can do the following things here :
<hr>
<li><a href="ran_num_gen/">Random number generator</a></li>
<hr>
<li><a href="ran_pwd_gen/">Random password generator</a></li>
<hr>
<li><a href="num_guess/">Random guess game</a></li>
<hr>

{% endblock content %}


i tried changing the name of links and adding the html extensions but it simply did not work.

我尝试更改链接的名称并添加html扩展名,但根本不起作用。


更多回答
优秀答案推荐

Use forward slashes rather than escape characters:

使用正斜杠而不是转义字符:


e.g.,

例如,


'home\ran_num_gen.html'

...becomes...

...变得...


'home/ran_num_gen.html'

...or...

...或者...


r'home\ran_num_gen.html'

更多回答

thanks, i used "r" and it started working .

谢谢,我用了“r”,它开始起作用了。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com