本项目为《跟老齐学Python:Django实战》的相关代码。
- mysite目录中是适合于Django1.x版本的源码,对应于《跟老齐学Python:Django实战》的第一版。
- mysite2目录中是适合于Django2.x版本的源码,对应于《跟老齐学Python:Django实战》的第二版。
- 鄙人的图书《跟老齐学Python:轻松入门》
- 鄙人的在线课程:Python3入门和提升
- 《跟老齐学Python》系列图书,各大网店和书店有售
《Django实战》源码(第一、第二版)
Home Page: http://www.itdiffer.com
本项目为《跟老齐学Python:Django实战》的相关代码。
$('#btnCrop').on('click', function(){
//alert("图片上传喽");
$.ajax({
url: '{% url "account:my_image" %}',
type: 'POST',
data: {"img": img},
success: function(e){
location.href= "{% url 'account:my_information' %}" },
});
});
photo=models.ImageField(max_length=15000,blank=True)
个人信息页面显示的图片只是剪裁图片页面所剪裁图片的的一小部分
第61页
if request.user.is_anonymous():
....
is_anonymous()方法上有@Property
所以不能这样调用
也不是什么大问题,不过如果书卖的好,以后再版时改一下,严谨一点好。
齐老师,您好,在django2.0中,展示个人信息这个章节中,按书中的例子输入代码,用get()会一直提示书中的那个错误,在网上百度了也没有找到解决方法以,求老师指点
您在书中关于缩略图的使用中使用了 sudo 管理员权限进行迁移, 然而在实际开发中似乎大家倾向于使用虚拟环境(Virtualenv等)进行开发
如此, 若使用sudo命令操作, 则使用的是系统的Python, 二者的库并不相同. 不知道您使用sudo的用意是什么?
我在实际操作中还是没有使用sudo, 目前得到的结果与书中是一致的.
Request Method: | GET |
---|---|
http://127.0.0.1:8002/article/article-content/7/python-language/ | |
2.0.1 | |
ConnectionError | |
Error 10061 connecting to localhost:6379. 由于目标计算机积极拒绝,无法连接。. | |
C:\Users\Adminliujing.virtualenvs\MyDjango7-6mb12HDd\lib\site-packages\redis\connection.py in connect, line 498 | |
C:\Users\Adminliujing.virtualenvs\MyDjango7-6mb12HDd\Scripts\python.exe | |
3.6.6 | |
['D:\MyDjango7\mysite', 'C:\Users\Adminliujing\.virtualenvs\MyDjango7-6mb12HDd\Scripts\python36.zip', 'C:\Users\Adminliujing\.virtualenvs\MyDjango7-6mb12HDd\DLLs', 'C:\Users\Adminliujing\.virtualenvs\MyDjango7-6mb12HDd\lib', 'C:\Users\Adminliujing\.virtualenvs\MyDjango7-6mb12HDd\Scripts', 'e:\python36\Lib', 'e:\python36\DLLs', 'C:\Users\Adminliujing\.virtualenvs\MyDjango7-6mb12HDd', 'C:\Users\Adminliujing\.virtualenvs\MyDjango7-6mb12HDd\lib\site-packages'] | |
星期四, 17 一月 2019 16:35:11 +0800 |
文件 ./blog/views.py里,blog_title()函数中 blogs = BlogArticles.objects.all(),提示Class 'BlogArticles' has no 'objects' member",请教下这个怎么解决下?
path('login/', auth_views.login, name='user_login'),
path('new-login/', auth_views.login, {'template_name': 'account/login.html'}, name='user_login'),
path('logout/', auth_views.logout, {'template_name': 'account/logout.html'}, name='user_logout'),
path('register/', views.register, name='user_register'),
path('password-change/', auth_views.password_change, {"post_change_redirect":"/account/password-change-done", 'template_name': 'account/password_change_form.html'}, name='password_change'),
path('password-change-done/', auth_views.password_change_done, {'template_name': 'account/password_change_done.html'}, name='password_change_done'),
path('password-reset/', auth_views.password_reset, {"template_name":"account/password_reset_form.html", "email_template_name":"account/password_reset_email.html", "subject_template_name":"account/password_reset_subject.txt", "post_reset_redirect":"/account/password-reset-done"}, name="password_reset"),
path('password-reset-done/', auth_views.password_reset_done, {"template_name":"account/password_reset_done.html"}, name="password_reset_done"),
path('password-reset-confirm///', auth_views.password_reset_confirm, {"template_name":"account/password_reset_confirm.html", "post_reset_redirect":"/account/password-reset-complete"}, name="password_reset_confirm"),
path('password-reset-complete/', auth_views.password_reset_complete, {"template_name":"account/password_reset_complete.html"}, name="password_reset_complete"),
上述代码中的内置方法,已经在django2.0不适用了,代码需修改,从以下模块中导入内置方法
from django.contrib.auth.views import LoginView
url中需修改为以下代码
path('login/', LoginView.as_view(), name='user_login'), # django内置登录
path('new-login/', LoginView.as_view(), {'template_name': 'account/login.html'}, name='user_login'),
齐老师,能在github上更新一下django2.0 当中的代码,有一些有错误,没有更正过来
齐老师,您好!
我用内置的方法重置密码的时候,向qq邮箱发送邮件时,网页显示已经发送了,但是qq邮箱并没有收到,肯能是什么原因啊
<script type="text/javascript" src= "{% static 'js/csrf.js'%}"></script>
$('#btnCrop').on('click', function(){
//alert("图片上传喽");
$.ajax({
url: '{% url "account:my_image" %}',
type: 'POST',
data: {"img": img},
success: function(e){
location.href= "{% url 'account:my_information' %}" },
});
});
按照教程, 但是点击OK后仍然不能提交
源码2.0中的Except语句缺少错误类型, 这容易给后期代码出错找错误带来麻烦, 建议补充相应的错误类型, 方便读者编程查错
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.