简体   繁体   English

Django:在模型文件中调用元类基础时出错

[英]Django: Error when calling the metaclass bases in Models File

I'm trying to use social-auth, and following the code in documentation. 我正在尝试使用social-auth,并遵循文档中的代码。 But, when I run 但是当我跑步

python manage.py convert_to_south

I'm getting the following error in my models.py 我在models.py中遇到以下错误

TypeError: Error when calling the metaclass bases
    module.__init__() takes at most 2 arguments (3 given)

This is my models file 这是我的模型文件

from django.db import models

# Create your models here.


class UsuarioManager(models.Manager):
    def create_user(self, username, email):
        return self.models._default_manager.create(username=username)


class Usuario(models):
    username = models.CharField(max_length=128)
    last_login = models.DateTimeField(blank=True, null=True)

    objects = UsuarioManager()

    def is_authenticated(self):
        return True

You are attempting to extend a module with this class is looks like while you may have intended to extend a class in the module: http://www.gossamer-threads.com/lists/python/python/905168 您正在尝试使用此类扩展模块,而您可能打算扩展模块中的类: http : //www.gossamer-threads.com/lists/python/python/905168

models.model looks like the the class you want to use: https://docs.djangoproject.com/en/1.8/topics/db/models/ models.model类似于您要使用的类: https : //docs.djangoproject.com/en/1.8/topics/db/models/

Do your code here would be: 您的代码在这里是:

from django.db import models

# Create your models here.


class UsuarioManager(models.Manager):
    def create_user(self, username, email):
        return self.models._default_manager.create(username=username)


class Usuario(models.model):
    username = models.CharField(max_length=128)
    last_login = models.DateTimeField(blank=True, null=True)

    objects = UsuarioManager()

    def is_authenticated(self):
        return True

following the example of: 遵循以下示例:

from django.db import models

class Person(models.Model):
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM