小编Ano*_*957的帖子

没有名为rest_auth的模块

得到错误:"ImportError:没有名为rest_auth的模块"

完整跟踪:https://dpaste.de/UHyx

当我尝试使用'python2.7 manage.py runserver'运行服务器时

我的伙伴正在和我一样工作,但是当他运行'python2.7 manage.py runserver'时能够成功运行服务器.我们都有相同的(我们相信)venv安装和包.

不太清楚可以做些什么来修复这个错误,因为我无法从跟踪中得到很多,但我相信我的python版本可能有问题..

python django python-2.7 django-rest-framework

9
推荐指数
1
解决办法
6069
查看次数

字段名称`username`对于模型无效

我试图使用rest-auth提供的序列化器来定义端点/rest-auth/user /的GET(*with headers)用户详细信息

(*with headers(Content-Type:application/json授权:Token 1a5472b2af03fc0e9de31fc0fc6dd81583087523))

我得到以下回溯:https://dpaste.de/oYay#L

我已经定义了自定义用户模型(使用电子邮件而不是用户名):

class UserManager(BaseUserManager):
def create_user(self, email, password, **kwargs):
    user = self.model(
        # lower-cases the host name of the email address
        # (everything right of the @) to avoid case clashes
        email=self.normalize_email(email),
        is_active=True,
        **kwargs
    )
    user.set_password(password)
    user.save(using=self._db)
    return user

def create_superuser(self, email, password, **kwargs):
    user = self.model(
        email=email,
        is_staff=True,
        is_superuser=True,
        is_active=True,
        **kwargs
    )
    user.set_password(password)
    user.save(using=self._db)
    return user


class MyUser(AbstractBaseUser, PermissionsMixin):
    USERNAME_FIELD = 'email'

    email = models.EmailField(unique=True)
Run Code Online (Sandbox Code Playgroud)

设置如下:

AUTH_USER_MODEL = …
Run Code Online (Sandbox Code Playgroud)

python django django-rest-framework django-allauth django-rest-auth

5
推荐指数
1
解决办法
2476
查看次数

@synthesize不再自动添加到.m文件中?

使用连接器连接按钮,文本字段和标签后,不会自动为标签和文本字段(两个都是出口)生成@synthesize语句,因此当我尝试访问标签或文本字段或其属性时. m文件它说"使用未声明的标识符",但Xcode不应该自动完成吗?我正在按照本教程http://www.youtube.com/watch?v=c3Yd2kCPs5c(大约4:35它显示自动生成的@synthesize语句,这些语句不再出现在xcode中)这就是我猜测导致此错误的原因.我不应该手动添加这些吗?解决这个问题的最佳方法是什么?

-------.m Fie--------
//
//  ViewController.m
//  AutoConnection
//
//  Created by Administrator on 29/03/13.
//  Copyright (c) 2013 Administrator. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)changeLabel:(id)sender {

    NSString *message = [[NSString alloc] initWithFormat:@"Hello %@", [myTextFeild …
Run Code Online (Sandbox Code Playgroud)

xcode objective-c ios

3
推荐指数
1
解决办法
3059
查看次数