Git Product home page Git Product logo

Comments (3)

polyrabbit avatar polyrabbit commented on May 28, 2024 1

Hi,

lambda **kw: 1 是指创建一个lambda方法,这个方法接受**kwargs这种命名参数,返回值永远是1,然后再把这个空方法赋值给u.save这个属性。我这样做是因为authenticate这个方法期望返回一个user对象,然后调用user.save()方法将这个用户存到数据库里,为了防止他将我虚拟出来的user也存到数据库里,我覆盖了真正usersave方法,使它永远返回成功,但是实际上却什么都没做。

WechatUser._meta.get_field('password').null = True
主要是WeCron的用户都是通过微信认证,而不是通过用户名密码认证,所以Django默认提供的password这个field就没有作用,但是Django的password默认是必须要有的,否则它的validator会通不过,这里通过将passwordnullable设为True告诉validator,这个password属性可以为空。

from wecron.

zanderzhg avatar zanderzhg commented on May 28, 2024

收到.谢谢您.

from wecron.

zanderzhg avatar zanderzhg commented on May 28, 2024

看了您的代码...惊喜不断...每个settings models views 里面都有收获

原来Django还可以这样写呀..真的感谢您能开源这个项目

from wecron.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.