Django在运行时出现Reverse for 'xxx' with no arguments not found.

本人刚学Django,这是一个临时程序,本来想实现通过url查找用户信息,并且在代码片段中添加了跳转链接

urls.py

from . import views
from django.conf.urls import url, include

urlpatterns = [
    url(r'^$',views.index,name='index'),
    url(r'^(?P<name_id>\d+)/$',views.names,name='names'),
]

views.py

from django.shortcuts import render
from .models import Name

# Create your views here.
def index(request):
    name = Name.objects.all()
    context = {'names':name}
    return render(request,'index.html',context)

def names(request, name_id):
    name = Name.objects.get(id=name_id)
    context = {'name':name}
    return render(request,'names.html',context)

index.py

<p>INDEX</p>
<!--这里想通过无序列表将用户名列出来-->
<ul>
    {% for name in names %}
        <!--本来想在此处插入跳转链接的,但是出错-->
        <li><a href="{% url 'testing:names' %}">{{ name }}</a></li>
    {% empty %}
        <li>NOTHING HERE</li>
    {% endfor %}
</ul>

以上就是主要的代码
报错如下:

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
怎么解决django__init__() takes 1 positional argument but 2 were given?
我在使用django框架制作网页的时候报错__init__() takes 1 positional argument but 2 were given。本来网页是没有错误的,只是添加登录界面之后点击登录就会报错。 这是login.html。 ![图片说明](https://img-ask.csdn.net/upload/202004/01/1585727719_997326.png) base.html父模板。 ![图片说明](https://img-ask.csdn.net/upload/202004/01/1585727772_550906.png) urls.py ![图片说明](https://img-ask.csdn.net/upload/202004/01/1585727872_816172.png) 报错内容。 ![图片说明](https://img-ask.csdn.net/upload/202004/01/1585727910_176346.png) 自己是大部分按照《Python编程从入门到实践》写的,前面Learning Log没有问题,就是user有问题。 ![图片说明](https://img-ask.csdn.net/upload/202004/01/1585728042_48879.png) 谁会解决先提前谢谢了!
执行pipenv run python manage.py runserver 0.0.0.0:8000系统检查报错name 'blog' is not defined,求解怎么解决?
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner self.run() File "/usr/lib/python3.6/threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "/home/jango/django-venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 54, in wrapper fn(*args, **kwargs) File "/home/jango/django-venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run self.check(display_num_errors=True) File "/home/jango/django-venv/lib/python3.6/site-packages/django/core/management/base.py", line 390, in check include_deployment_checks=include_deployment_checks, File "/home/jango/django-venv/lib/python3.6/site-packages/django/core/management/base.py", line 377, in _run_checks return checks.run_checks(**kwargs) File "/home/jango/django-venv/lib/python3.6/site-packages/django/core/checks/registry.py", line 72, in run_checks new_errors = check(app_configs=app_configs) File "/home/jango/django-venv/lib/python3.6/site-packages/django/core/checks/urls.py", line 13, in check_url_config return check_resolver(resolver) File "/home/jango/django-venv/lib/python3.6/site-packages/django/core/checks/urls.py", line 23, in check_resolver return check_method() File "/home/jango/django-venv/lib/python3.6/site-packages/django/urls/resolvers.py", line 398, in check for pattern in self.url_patterns: File "/home/jango/django-venv/lib/python3.6/site-packages/django/utils/functional.py", line 80, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/home/jango/django-venv/lib/python3.6/site-packages/django/urls/resolvers.py", line 579, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/home/jango/django-venv/lib/python3.6/site-packages/django/utils/functional.py", line 80, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/home/jango/django-venv/lib/python3.6/site-packages/django/urls/resolvers.py", line 572, in urlconf_module return import_module(self.urlconf_name) File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/home/jango/django-one/blogproject/blogproject/urls.py", line 7, in <module> path('', include('blog.urls')), File "/home/jango/django-venv/lib/python3.6/site-packages/django/urls/conf.py", line 34, in include urlconf_module = import_module(urlconf_module) File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/home/jango/django-one/blogproject/blog/urls.py", line 3, in <module> from . import views File "/home/jango/django-one/blogproject/blog/views.py", line 1, in <module> blog/views.py NameError: name 'blog' is not defined
ubuntu服务器Django部署到本地,但网页拒绝访问
问题如题目所述,我在服务器上建立了一个django测试项目,执行命令: ``` python manage.py runserver ``` 后得到以下结果: ![图片说明](https://img-ask.csdn.net/upload/202003/28/1585388701_810795.png) 但在浏览器中输入地址,发现拒绝访问 ![图片说明](https://img-ask.csdn.net/upload/202003/28/1585388816_60475.png) 尝试了网上的一些方法,如:修改允许的主机,打开8000端口,但没有效果,因为之前在Windows上做django项目时一切正常,而且本人服务器操作小白一名,所以怀疑可能是自己服务器没设置好,希望各位大佬赐教。 win10环境,用的是亚马逊Ubuntu服务器
执行python manage.py runserver 0.0.0.0:8000无响应
Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. Run 'python manage.py migrate' to apply them. March 28, 2020 - 10:10:09 Django version 3.0.4, using settings 'firstdjangopro.settings' Starting development server at http://0.0.0.0:8000/ Quit the server with CONTROL-C. 到这里就结束了,后续无响应,未报错误
Django配置MySQL,运行python manage.py startapp myapp 报错!!
python manage.py startapp myapp Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line utility.execute() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 357, in execute django.setup() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 114, in populate app_config.import_models() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\config.py", line 211, in import_models self.models_module = import_module(models_module_name) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\contrib\auth\models.py", line 2, in <module> from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\contrib\auth\base_user.py", line 47, in <module> class AbstractBaseUser(models.Model): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\base.py", line 117, in __new__ new_class.add_to_class('_meta', Options(meta, app_label)) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\base.py", line 321, in add_to_class value.contribute_to_class(cls, name) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\options.py", line 204, in contribute_to_class self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\__init__.py", line 28, in __getattr__ return getattr(connections[DEFAULT_DB_ALIAS], item) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\utils.py", line 201, in __getitem__ backend = load_backend(db['ENGINE']) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\utils.py", line 110, in load_backend return import_module('%s.base' % backend_name) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\mysql\base.py", line 36, in <module> raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__) django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3. da
Django框架通过pip安装,直接copy了一份代码但是在VS CODE上运行不了
显示的是 Note that only Django core commands are listed as settings are not properly configured (error: No module named 'django.core.urlresolvers').
在学习Django创建模型,连接MySQL数据库,生成迁移文件时出错,求大佬帮解决下
这是我学习时的笔记: https://blog.csdn.net/u013916480/article/details/104819213 ``` D:\software\Django_project\project_test>python manage.py makemigrations Traceback (most recent call last): File "C:\Users\fengrui\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\base\base.py", line 217, in ensure_connection self.connect() File "C:\Users\fengrui\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\base\base.py", line 195, in connect self.connection = self.get_new_connection(conn_params) File "C:\Users\fengrui\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\sqlite3\base.py", line 194, in get_new_connection conn = Database.connect(**conn_params) sqlite3.OperationalError: unable to open database file The above exception was the direct cause of the following exception: Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "C:\Users\fengrui\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line utility.execute() File "C:\Users\fengrui\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Users\fengrui\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv self.execute(*args, **cmd_options) File "C:\Users\fengrui\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 364, in execute output = self.handle(*args, **options) File "C:\Users\fengrui\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 83, in wrapped res = handle_func(*args, **kwargs) File "C:\Users\fengrui\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\commands\makemigrations.py", line 101, in handle loader.check_consistent_history(connection) File "C:\Users\fengrui\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\loader.py", line 283, in check_consistent_history applied = recorder.applied_migrations() File "C:\Users\fengrui\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\recorder.py", line 73, in applied_migrations if self.has_table(): File "C:\Users\fengrui\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\recorder.py", line 56, in has_table return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()) File "C:\Users\fengrui\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\base\base.py", line 256, in cursor return self._cursor() File "C:\Users\fengrui\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\base\base.py", line 233, in _cursor self.ensure_connection() File "C:\Users\fengrui\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\base\base.py", line 217, in ensure_connection self.connect() File "C:\Users\fengrui\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\utils.py", line 89, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "C:\Users\fengrui\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\base\base.py", line 217, in ensure_connection self.connect() File "C:\Users\fengrui\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\base\base.py", line 195, in connect self.connection = self.get_new_connection(conn_params) File "C:\Users\fengrui\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\sqlite3\base.py", line 194, in get_new_connection conn = Database.connect(**conn_params) django.db.utils.OperationalError: unable to open database file ```
windows下Django运行python manage.py runserver时报错LookupError: No installed app with label 'admin'.
Pycharm用Django框架时想连接远程数据库,但是在运行服务器时python manage.py runserver显示LookupError: No installed app with label 'admin'.
Django创建第一个项目
django创建hello world 已经运行了(图一) 但是在浏览器打开没有hello world 而是一堆看不懂的(图二) ![图片说明](https://img-ask.csdn.net/upload/202003/04/1583303679_641965.png) ![图片说明](https://img-ask.csdn.net/upload/202003/04/1583303760_268955.png)
求助:Nginx+Gunicorn部署 Django后遇到Not Found错误
问题描述: Nginx+Gunicorn部署 Django后遇到Not Found错误 ![图片说明](https://img-ask.csdn.net/upload/202003/09/1583754685_161046.png) 服务器版本:CentOS 7.5 x64 说明:在虚拟环境中使用django自带的runserver运行(0.0.0.0:8000)后,使用公网IP:端口/index可以正常访问项目,关闭debug后使用 ``` pipenv run gunicorn blogproject.wsgi -w 2 -k gthread -b 0.0.0.0:8000 ``` 运行也可以正常访问,但是开启nginx后运行就出现如图错误。 /etc/nginx/conf.d/django-blog.conf配置如下 ``` [zijeak@VM_16_8_centos conf.d]$ cat django-blog.conf server { charset utf-8; listen 80; server_name 119.27.169.70; location /static { alias /home/zijeak/apps/django-blog/static; } location / { proxy_set_header Host $host; proxy_pass http://127.0.0.1:8000; } } ``` 查看nginx日志如下: ``` [zijeak@VM_16_8_centos conf.d]$ sudo nginx -t [sudo] password for zijeak: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful ``` 项目目录如下: ![图片说明](https://img-ask.csdn.net/upload/202003/09/1583755294_598395.png)
(1054, "Unknown column 'user' in 'field list'") django用户注册报错
想用django实现注册功能,但是会出现这样的错误 看好多博客说跟数据库名字有关,也看不懂,改不明白啊,改了一下午了, 大佬们!路过帮帮忙!
python+django+mysql做一个校友信息管理系统?
编程(Python)实现大学校友的个人信息管理网站,具有友好人机交互界面,具备对校友基本信息的增删改查功能。基于的django的Python web开发,实现管理员登录和学生登录,要求学生本人使用学号注册登录,填写个人信息。管理员使用账号登陆,可以对已有学生的信息增删改查,排序,统计学生个数,显示所有学生信息功能。后台数据库使用MySQL,
nginx 400错误,哪位大佬救救我
nginx配置信息 ``` user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; client_header_buffer_size 128k; large_client_header_buffers 4 128k; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; include /etc/nginx/conf.d/*.conf; upstream app_server { # for UNIX domain socket setups server unix:/webapps/learning_log/gunicorn.sock fail_timeout=0; } server { charset utf-8; listen 80; server_name www.xxxxxxxxxxxx.tk; # 日志 access_log /webapps/learning_log/logs/nginx.access.log; error_log /webapps/learning_log/logs/nginx.error.log; # 不记录访问不到 favicon.ico 的报错日志 location = /favicon.ico { access_log off; log_not_found off; } # static 和 media 的地址 location /static {#注意!!!:static后面不能有/斜杠,否则会导致静态文件404 alias /webapps/learning_log/static; } location /media { alias /webapps/learning_log/media; } location / { proxy_pass http://app_server; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } server { listen 80; server_name xxxxxxxxxxxx.tk; rewrite ^(.*) http://www.xxxxxxxxxxxx.tk$1 permanent; } ``` gunicorn运行正常 nginx_error.log ``` 2020/03/31 14:40:12 [crit] 90216#90216: *2 connect() to unix:/webapps/learning_log/gunicorn.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.229.1, server: www.perry-in-the-sky.tk, request: "GET / HTTP/1.1", upstream: "http://unix:/webapps/learning_log/gunicorn.sock:/", host: "www.perry-in-the-sky.tk" ```
Django runserver运行之后,可以显示标题,但是内容显示不了,可以怎么整?
![图片说明](https://img-ask.csdn.net/upload/202002/28/1582873565_219892.png)
Django在通过admin登录django自带后台的时候遇到了302问题,应该怎么解决?
最近学Django,跟着书本和教程做了几个网站当练习,但在创建好superuser, 用http://127.0.0.1:8000/admin 登录django自带的后台的时候出现了302提示 ![图片说明](https://img-ask.csdn.net/upload/202002/02/1580630195_708850.png) 然后django就自动断开了。。。。。。 因为这个练习是刚开始做,想看下代码有没问题就还只写了model.py和admin.py,admin.py只是对模型注册了下,没有写任何其他的代码,所以不清楚是哪里出了问题。 谷歌了一下,虽然也有碰到类似问题的朋友但回答基本都不顶用,所以来论坛求救,有哪位大神知道什么原因吗?谢谢!! PS:之前做的几个练习都好的,但最近因为出现这个问题就重新运行了下,结果也出现302的提示。。。。。。。
Django 写的登陆功能,当我登陆时,form.is_valid() 总是返回false,并提示用户名已存在
#### models.py代码: ``` from django.db import models class User(models.Model): account = models.CharField(max_length=255, primary_key=True) passwd = models.CharField(max_length=255) def __str__(self): return self.account class Meta: db_table = "user" ``` #### form.py代码: ``` from django import forms from user.models import User class UserForm(forms.ModelForm): account = forms.CharField(label='账号', required=True) passwd = forms.CharField(label='密码', widget=forms.PasswordInput(), required=True) class Meta: model = User fields = {'account', 'passwd'} ``` #### 登陆代码段: ``` def login(request): if request.method == 'POST': form = UserForm(request.POST) # 关联前端表单数据 和 后台表单类 if form.is_valid(): # 验证表单数据是否合法 account = form.cleaned_data['account'] passwd = form.cleaned_data['passwd'] user = User.objects.filter(account=account) if user: if check_password(passwd, user.passwd): return HttpResponse('登陆成功!') else: return HttpResponse('密码错误!') else: return HttpResponse('用户不存在!') else: return HttpResponse(str(form.errors)) else: form = UserForm() return render(request, 'user/login.html', {'form': form}) ``` #### 注册代码段: ``` def register(request): if request.method == 'POST': user = User() form = UserForm(request.POST) if form.is_valid(): pwd = form.cleaned_data['passwd'] user = form.save(commit=False) user.passwd = make_password(pwd, None, 'pbkdf2_sha256') user.save() return HttpResponse('注册成功!') else: return HttpResponse(str(form.errors)) # try: # user.save(force_insert=True) # except IntegrityError: # return HttpResponse('账号重复!') # return HttpResponse('注册成功!') else: form = UserForm() return render(request, 'user/register.html', {'form': form}) ``` 当我登陆时, **form.is_valid()** 会显示false,无法进入到保存数据库的代码段中。并且 **form.errors** 会显示如下信息。 ![图片说明](https://img-ask.csdn.net/upload/202003/23/1584971497_645144.png) 我估计是它把我的这一步理解成要新建数据了,但是我的登陆代码里完全没有与save有关的代码。而且程序在运行到 **form = UserForm(request.POST)** ,但还有没有到 **form.is_valid()** 的时候,就可以发现这个错误已经出现了。不知道是为什么。
Django开发网站时出错。
本人技术渣一枚,这几天刚入坑的Django,按照网上的教程一步步来的,到这里的时候不知道为什么出错了,求大神解答一下 ![图片说明](https://img-ask.csdn.net/upload/202002/18/1582037665_342899.png) 这里是我的new_entry文件代码 ![图片说明](https://img-ask.csdn.net/upload/202002/18/1582037695_149108.png)
Django创建超级用户时,出现错误 ValueError: invalid literal for int() with base 10: ''
ERROR exception 135 Internal Server Error: /users/ Traceback (most recent call last): File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/core/handlers/exception.py", line 41, in inner response = get_response(request) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view return view_func(*args, **kwargs) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/views/generic/base.py", line 68, in view return self.dispatch(request, *args, **kwargs) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/rest_framework/views.py", line 505, in dispatch response = self.handle_exception(exc) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/rest_framework/views.py", line 465, in handle_exception self.raise_uncaught_exception(exc) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception raise exc File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/rest_framework/views.py", line 502, in dispatch response = handler(request, *args, **kwargs) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/rest_framework/generics.py", line 242, in post return self.create(request, *args, **kwargs) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/rest_framework/mixins.py", line 19, in create self.perform_create(serializer) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/rest_framework/mixins.py", line 24, in perform_create serializer.save() File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/rest_framework/serializers.py", line 213, in save self.instance = self.create(validated_data) File "/home/python/dihai02/per02/apps/users/serializers/user.py", line 25, in create user = User.objects.create_user(**validated_data) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/contrib/auth/models.py", line 159, in create_user return self._create_user(username, email, password, **extra_fields) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/contrib/auth/models.py", line 153, in _create_user user.save(using=self._db) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/contrib/auth/base_user.py", line 80, in save super(AbstractBaseUser, self).save(*args, **kwargs) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/base.py", line 808, in save force_update=force_update, update_fields=update_fields) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/base.py", line 838, in save_base updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/base.py", line 924, in _save_table result = self._do_insert(cls._base_manager, using, fields, update_pk, raw) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/base.py", line 963, in _do_insert using=using, raw=raw) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/query.py", line 1076, in _insert return query.get_compiler(using=using).execute_sql(return_id) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1111, in execute_sql for sql, params in self.as_sql(): File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1064, in as_sql for obj in self.query.objs File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1064, in <listcomp> for obj in self.query.objs File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1063, in <listcomp> [self.prepare_value(field, self.pre_save_val(field, obj)) for field in fields] File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1003, in prepare_value value = field.get_db_prep_save(value, connection=self.connection) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/fields/__init__.py", line 770, in get_db_prep_save prepared=False) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/fields/__init__.py", line 762, in get_db_prep_value value = self.get_prep_value(value) File "/home/python/.virtualenvs/yuan/lib/python3.7/site-packages/django/db/models/fields/__init__.py", line 1853, in get_prep_value return int(value) ValueError: invalid literal for int() with base 10: ''
拉勾网爬取数据问题,请帮忙看看谢谢
from urllib import request from urllib import parse url="https://www.lagou.com/jobs/positionAjax.json?city=%E6%88%90%E9%83%BD&needAddtionalResult=false" header = { "Accept": "application/json, text/javascript, */*; q=0.01", "Accept-Encoding": "gzip, deflate, br", "Accept-Language": "zh-CN,zh;q=0.9", "Connection": "keep-alive", "Content-Length": 25, "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "Cookie":"_ga=GA1.2.1138539770.1585636133; _gid=GA1.2.1776239920.1585636133; user_trace_token=20200331142853-c1dac458-3664-4392-ac4a-69c04bd926ad; LGUID=20200331142853-dc342d00-8bd1-4ef0-be94-e1fc963c7f66; index_location_city=%E6%88%90%E9%83%BD; sajssdk_2015_cross_new_user=1; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%221712f483c25225-00fccc2a691313-f313f6d-1049088-1712f483c2633d%22%2C%22%24device_id%22%3A%221712f483c25225-00fccc2a691313-f313f6d-1049088-1712f483c2633d%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_referrer%22%3A%22%22%2C%22%24latest_referrer_host%22%3A%22%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%7D%7D; JSESSIONID=ABAAAECABBJAAGI1DC0715445E99FC390A39784928682B0; WEBTJ-ID=20200331143339-1712f4ba93753-01b5d59a319d9f-f313f6d-1049088-1712f4ba939425; Hm_lvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1585636134,1585636420; LGSID=20200331152720-18ff9ecf-6dde-4b69-a5ac-cafab6f4470c; PRE_UTM=; PRE_HOST=; PRE_SITE=https%3A%2F%2Fwww.lagou.com%2F; PRE_LAND=https%3A%2F%2Fwww.lagou.com%2Fjobs%2Flist%5Fpython%3FlabelWords%3D%26fromSearch%3Dtrue%26suginput%3D; lagou_utm_source=A; gate_login_token=ab68787e51ce7cdc4177f8a0dc2bf580b680d718f0c2da0c; _putrc=08BDB62514E63F98; login=true; unick=%E7%A8%8B%E5%AE%87%E9%BE%99; _gat=1; showExpriedIndex=1; showExpriedCompanyHome=1; showExpriedMyPublish=1; hasDeliver=0; X_HTTP_TOKEN=0e03eaf6286772819580465851933e81482e1a7c06; Hm_lpvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1585640860; privacyPolicyPopup=false; TG-TRACK-CODE=index_search; LGRID=20200331154749-a4a36d65-c7eb-4afb-ad17-70b31d6f293b; SEARCH_ID=6b9fa4ae7fe44a208c3dc67ed1ec3e44", "Host": "www.lagou.com", "Origin": "https://www.lagou.com", "Referer":"https://www.lagou.com/jobs/list_python?labelWords=&fromSearch=true&suginput=", 'Upgrade-Insecure-Requests': '1', "Sec-Fetch-Dest": "empty", "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-origin", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36", "X-Anit-Forge-Code": "0", "X-Anit-Forge-Token": "None", "X-Requested-With": "XMLHttpRequest", } data = { "first":"true", "pn":1, "kd":"python" } host = { "Host":"www.lagou.com" } req = request.Request(url,headers=header,data=parse.urlencode(data).encode("utf-8"),origin_req_host=parse.urlencode(host),method="POST") resp = request.urlopen(req) print(resp.read().decode("utf-8")) 代码如上,只是想爬取对应的职位信息,但是始终不行,一直提示 {"status":false,"msg":"您操作太频繁,请稍后再访问","clientIp":"117.139.247.197","state":2402} 但是用网页操作又是好的,url地址,是position.Ajax.json里面找的,然后在header这里把所有的内容都复制出来了,还是不行,请知道的告诉下,是不是又升级了啊,如何解决呢?谢谢了
在中国程序员是青春饭吗?
今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...
《MySQL 性能优化》之理解 MySQL 体系结构
本文介绍 MySQL 的体系结构,包括物理结构、逻辑结构以及插件式存储引擎。
程序员请照顾好自己,周末病魔差点一套带走我。
程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。
复习一周,京东+百度一面,不小心都拿了Offer
京东和百度一面都问了啥,面试官百般刁难,可惜我全会。
Java 14 都快来了,为什么还有这么多人固守Java 8?
从Java 9开始,Java版本的发布就让人眼花缭乱了。每隔6个月,都会冒出一个新版本出来,Java 10 , Java 11, Java 12, Java 13, 到2020年3月份,...
达摩院十大科技趋势发布:2020 非同小可!
【CSDN编者按】1月2日,阿里巴巴发布《达摩院2020十大科技趋势》,十大科技趋势分别是:人工智能从感知智能向认知智能演进;计算存储一体化突破AI算力瓶颈;工业互联网的超融合;机器间大规模协作成为可能;模块化降低芯片设计门槛;规模化生产级区块链应用将走入大众;量子计算进入攻坚期;新材料推动半导体器件革新;保护数据隐私的AI技术将加速落地;云成为IT技术创新的中心 。 新的画卷,正在徐徐展开。...
轻松搭建基于 SpringBoot + Vue 的 Web 商城应用
首先介绍下在本文出现的几个比较重要的概念: 函数计算(Function Compute): 函数计算是一个事件驱动的服务,通过函数计算,用户无需管理服务器等运行情况,只需编写代码并上传。函数计算准备计算资源,并以弹性伸缩的方式运行用户代码,而用户只需根据实际代码运行所消耗的资源进行付费。Fun: Fun 是一个用于支持 Serverless 应用部署的工具,能帮助您便捷地管理函数计算、API ...
讲真,这两个IDE插件,可以让你写出质量杠杠的代码
周末躺在床上看《拯救大兵瑞恩》 周末在闲逛的时候,发现了两个优秀的 IDE 插件,据说可以提高代码的质量,我就安装了一下,试了试以后发现,确实很不错,就推荐给大家。 01、Alibaba Java 代码规范插件 《阿里巴巴 Java 开发手册》,相信大家都不会感到陌生,其 IDEA 插件的下载次数据说达到了 80 万次,我今天又贡献了一次。嘿嘿。 该项目的插件地址: https://github....
Python+OpenCV实时图像处理
目录 1、导入库文件 2、设计GUI 3、调用摄像头 4、实时图像处理 4.1、阈值二值化 4.2、边缘检测 4.3、轮廓检测 4.4、高斯滤波 4.5、色彩转换 4.6、调节对比度 5、退出系统 初学OpenCV图像处理的小伙伴肯定对什么高斯函数、滤波处理、阈值二值化等特性非常头疼,这里给各位分享一个小项目,可通过摄像头实时动态查看各类图像处理的特点,也可对各位调参、测试...
2020年一线城市程序员工资大调查
人才需求 一线城市共发布岗位38115个,招聘120827人。 其中 beijing 22805 guangzhou 25081 shanghai 39614 shenzhen 33327 工资分布 2020年中国一线城市程序员的平均工资为16285元,工资中位数为14583元,其中95%的人的工资位于5000到20000元之间。 和往年数据比较: yea...
为什么猝死的都是程序员,基本上不见产品经理猝死呢?
相信大家时不时听到程序员猝死的消息,但是基本上听不到产品经理猝死的消息,这是为什么呢? 我们先百度搜一下:程序员猝死,出现将近700多万条搜索结果: 搜索一下:产品经理猝死,只有400万条的搜索结果,从搜索结果数量上来看,程序员猝死的搜索结果就比产品经理猝死的搜索结果高了一倍,而且从下图可以看到,首页里面的五条搜索结果,其实只有两条才是符合条件。 所以程序员猝死的概率真的比产品经理大,并不是错...
害怕面试被问HashMap?这一篇就搞定了!
声明:本文以jdk1.8为主! 搞定HashMap 作为一个Java从业者,面试的时候肯定会被问到过HashMap,因为对于HashMap来说,可以说是Java集合中的精髓了,如果你觉得自己对它掌握的还不够好,我想今天这篇文章会非常适合你,至少,看了今天这篇文章,以后不怕面试被问HashMap了 其实在我学习HashMap的过程中,我个人觉得HashMap还是挺复杂的,如果真的想把它搞得明明白...
毕业5年,我问遍了身边的大佬,总结了他们的学习方法
我问了身边10个大佬,总结了他们的学习方法,原来成功都是有迹可循的。
python爬取百部电影数据,我分析出了一个残酷的真相
2019年就这么匆匆过去了,就在前几天国家电影局发布了2019年中国电影市场数据,数据显示去年总票房为642.66亿元,同比增长5.4%;国产电影总票房411.75亿元,同比增长8.65%,市场占比 64.07%;城市院线观影人次17.27亿,同比增长0.64%。 看上去似乎是一片大好对不对?不过作为一名严谨求实的数据分析师,我从官方数据中看出了一点端倪:国产票房增幅都已经高达8.65%了,为什...
推荐10个堪称神器的学习网站
每天都会收到很多读者的私信,问我:“二哥,有什么推荐的学习网站吗?最近很浮躁,手头的一些网站都看烦了,想看看二哥这里有什么新鲜货。” 今天一早做了个恶梦,梦到被老板辞退了。虽然说在我们公司,只有我辞退老板的份,没有老板辞退我这一说,但是还是被吓得 4 点多都起来了。(主要是因为我掌握着公司所有的核心源码,哈哈哈) 既然 4 点多起来,就得好好利用起来。于是我就挑选了 10 个堪称神器的学习网站,推...
这些软件太强了,Windows必装!尤其程序员!
Windows可谓是大多数人的生产力工具,集娱乐办公于一体,虽然在程序员这个群体中都说苹果是信仰,但是大部分不都是从Windows过来的,而且现在依然有很多的程序员用Windows。 所以,今天我就把我私藏的Windows必装的软件分享给大家,如果有一个你没有用过甚至没有听过,那你就赚了????,这可都是提升你幸福感的高效率生产力工具哦! 走起!???? NO、1 ScreenToGif 屏幕,摄像头和白板...
阿里面试,面试官没想到一个ArrayList,我都能跟他扯半小时
我是真的没想到,面试官会这样问我ArrayList。
曾经优秀的人,怎么就突然不优秀了。
职场上有很多辛酸事,很多合伙人出局的故事,很多技术骨干被裁员的故事。说来模板都类似,曾经是名校毕业,曾经是优秀员工,曾经被领导表扬,曾经业绩突出,然而突然有一天,因为种种原因,被裁员了,...
大学四年因为知道了这32个网站,我成了别人眼中的大神!
依稀记得,毕业那天,我们导员发给我毕业证的时候对我说“你可是咱们系的风云人物啊”,哎呀,别提当时多开心啦????,嗯,我们导员是所有导员中最帅的一个,真的???? 不过,导员说的是实话,很多人都叫我大神的,为啥,因为我知道这32个网站啊,你说强不强????,这次是绝对的干货,看好啦,走起来! PS:每个网站都是学计算机混互联网必须知道的,真的牛杯,我就不过多介绍了,大家自行探索,觉得没用的,尽管留言吐槽吧???? 社...
良心推荐,我珍藏的一些Chrome插件
上次搬家的时候,发了一个朋友圈,附带的照片中不小心暴露了自己的 Chrome 浏览器插件之多,于是就有小伙伴评论说分享一下我觉得还不错的浏览器插件。 我下面就把我日常工作和学习中经常用到的一些 Chrome 浏览器插件分享给大家,随便一个都能提高你的“生活品质”和工作效率。 Markdown Here Markdown Here 可以让你更愉快的写邮件,由于支持 Markdown 直接转电子邮...
看完这篇HTTP,跟面试官扯皮就没问题了
我是一名程序员,我的主要编程语言是 Java,我更是一名 Web 开发人员,所以我必须要了解 HTTP,所以本篇文章就来带你从 HTTP 入门到进阶,看完让你有一种恍然大悟、醍醐灌顶的感觉。 最初在有网络之前,我们的电脑都是单机的,单机系统是孤立的,我还记得 05 年前那会儿家里有个电脑,想打电脑游戏还得两个人在一个电脑上玩儿,及其不方便。我就想为什么家里人不让上网,我的同学 xxx 家里有网,每...
2020 年,大火的 Python 和 JavaScript 是否会被取而代之?
Python 和 JavaScript 是目前最火的两大编程语言,但是2020 年,什么编程语言将会取而代之呢? 作者 |Richard Kenneth Eng 译者 |明明如月,责编 | 郭芮 出品 | CSDN(ID:CSDNnews) 以下为译文: Python 和 JavaScript 是目前最火的两大编程语言。然而,他们不可能永远屹立不倒。最终,必将像其他编程语言一...
史上最全的IDEA快捷键总结
现在Idea成了主流开发工具,这篇博客对其使用的快捷键做了总结,希望对大家的开发工作有所帮助。
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
谁是华为扫地僧?
是的,华为也有扫地僧!2020年2月11-12日,“养在深闺人不知”的华为2012实验室扫地僧们,将在华为开发者大会2020(Cloud)上,和大家见面。到时,你可以和扫地僧们,吃一个洋...
Idea 中最常用的10款插件(提高开发效率),一定要学会使用!
学习使用一些插件,可以提高开发效率。对于我们开发人员很有帮助。这篇博客介绍了开发中使用的插件。
AI 没让人类失业,搞 AI 的人先失业了
最近和几个 AI 领域的大佬闲聊 根据他们讲的消息和段子 改编出下面这个故事 如有雷同 都是巧合 1. 老王创业失败,被限制高消费 “这里写我跑路的消息实在太夸张了。” 王葱葱哼笑一下,把消息分享给群里。 阿杰也看了消息,笑了笑。在座几位也都笑了。 王葱葱是个有名的人物,21岁那年以全额奖学金进入 KMU 攻读人工智能博士,累计发表论文 40 余篇,个人技术博客更是成为深度学习领域内风向标。 ...
2020年,冯唐49岁:我给20、30岁IT职场年轻人的建议
点击“技术领导力”关注∆每天早上8:30推送 作者|Mr.K 编辑| Emma 来源|技术领导力(ID:jishulingdaoli) 前天的推文《冯唐:职场人35岁以后,方法论比经验重要》,收到了不少读者的反馈,觉得挺受启发。其实,冯唐写了不少关于职场方面的文章,都挺不错的。可惜大家只记住了“春风十里不如你”、“如何避免成为油腻腻的中年人”等不那么正经的文章。 本文整理了冯...
作为一名大学生,如何在B站上快乐的学习?
B站是个宝,谁用谁知道???? 作为一名大学生,你必须掌握的一项能力就是自学能力,很多看起来很牛X的人,你可以了解下,人家私底下一定是花大量的时间自学的,你可能会说,我也想学习啊,可是嘞,该学习啥嘞,不怕告诉你,互联网时代,最不缺的就是学习资源,最宝贵的是啥? 你可能会说是时间,不,不是时间,而是你的注意力,懂了吧! 那么,你说学习资源多,我咋不知道,那今天我就告诉你一个你必须知道的学习的地方,人称...
那些年,我们信了课本里的那些鬼话
教材永远都是有错误的,从小学到大学,我们不断的学习了很多错误知识。 斑羚飞渡 在我们学习的很多小学课文里,有很多是错误文章,或者说是假课文。像《斑羚飞渡》: 随着镰刀头羊的那声吼叫,整个斑羚群迅速分成两拨,老年斑羚为一拨,年轻斑羚为一拨。 就在这时,我看见,从那拨老斑羚里走出一只公斑羚来。公斑羚朝那拨年轻斑羚示意性地咩了一声,一只半大的斑羚应声走了出来。一老一少走到伤心崖,后退了几步,突...
立即提问

相似问题

1
django如何获取for循环中的某一条数据
1
Django报错 求助 ModuleNotFoundError: No module named '__main__.views'; '__main__' is not a package
2
django中创建表python manage.py makemigrations出现以下错误 ,望大神指导
1
django中 django.db.utils.ProgrammingError: (1146, "Table 'xxx' doesn't exist")的问题
2
Django实现Web应用显示单个主题时出现错误: 'function' object has no attribute 'entry_set'
4
Django在cmd启动报错:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc7
1
django创建项目时,urls.py报错:No module named 'index.urls'
2
pycharm编写django项目导入pymsql报错:ModuleNotFoundError: No module named 'pymysql'
2
如何把Django+sqlite应用打包发布成可独立运行的桌面程序?
0
django 运行 python manage.py runserver 显示No module named 'tutorial.quickstart' 无法安装tutorial
4
windows下Django运行python manage.py runserver时报错LookupError: No installed app with label 'admin'.
2
django启动服务时报错 UnicodeDecodeError: 'utf8' codec can't decode byte 0xcb
1
Pycharm创建Django项目时配置虚拟环境报错
2
python3.7,django 2.21,for...in...Python int too large to convert to C long
0
django、subprocess多进程 报错django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
1
django 模板for循环嵌套
1
django开发需要与硬件设备交互
0
从Github导入Django项目运行时报如下错误:
2
Django 模板标签<% for i in list%> 为什么显示不出来?
1
django怎样在两个VIEWS之间传递数据