标签: django-registration

Django 1.6和django-registration:内置的身份验证视图未被提取

我正在尝试将我的webapp从Django 1.5升级到Django 1.6,并且作为我的django应用程序集的一部分,我正在使用django-registration 1.0.

升级到Django 1.6后,我的应用程序无法识别内置的身份验证视图.它们都集成在Django登记可以看出这里,但他们停止工作.

Django发行说明描述了这些视图应该集成的方式变化,将其与注册应用程序中看起来很好的源代码进行比较.

我正在介绍注册网址如下:

urlpatterns = patterns('',
     ...,
     url(r'^accounts/', include('registration.backends.default.urls')),
)
Run Code Online (Sandbox Code Playgroud)

我在请求内置网址时遇到错误,例如 /accounts/password/change/

django.core.urlresolvers.NoReverseMatch

NoReverseMatch: Reverse for 'password_change_done' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Run Code Online (Sandbox Code Playgroud)

有谁知道为什么我会得到无反向匹配错误?

django url-pattern django-registration django-1.6

19
推荐指数
2
解决办法
7791
查看次数

Django - 身份验证,注册电子邮件确认

我正在查看用于身份验证的API

https://docs.djangoproject.com/en/1.3/topics/auth/

我似乎无法找到有关简单用户注册表单的信息,因为它是发送确认电子邮件,因为它是网站上的常用方式.

我想我能做到这一点:

1)显示表格2)用户输入信息并提交3)将用户保存为非活动状态,并带有确认码4)发送带有确认码的链接5)用户点击确认链接并激活

这似乎并不困难,但我有一种感觉,这可能已经完成,而且还有一些需要考虑的边缘情况.

python authentication django django-registration

17
推荐指数
2
解决办法
2万
查看次数

django-registration"记住我"

我需要在使用django-registration app的登录表单中实现"记住我"按钮.任何人都可以帮助我告诉我这样做的方法吗?

谢谢

django django-registration

13
推荐指数
1
解决办法
5987
查看次数

使用参数'()'和关键字参数'{}'找不到'index'.尝试过0种模式:[]

我正试图让django-register在我的网站上工作,但我一直收到这个我不明白的错误

我在Python 3.3上使用django 1.6

NoReverseMatch at /accounts/register/
Reverse for 'index' with arguments '()' and keyword arguments '{}' not     found. 0 pattern(s) tried: []
    Request Method: GET
Request URL:    http://127.0.0.1:8000/accounts/register/
Django Version: 1.6.1
Exception Type: NoReverseMatch
Exception Value:    
Reverse for 'index' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Exception Location: D:\Programming\Py33\lib\site-packages\django\core\urlresolvers.py in _reverse_with_prefix, line 429
Python Executable:  D:\Programming\Py33\python.exe
Python Version: 3.3.3
Python Path:    
['D:\\Programming\\GItHub\\photobyte\\PhotoByte',
 'D:\\Programming\\Py33\\lib\\site-packages\\setuptools-2.0.3dev-py3.3.egg',
 'C:\\WINDOWS\\SYSTEM32\\python33.zip',
 'D:\\Programming\\Py33\\DLLs',
 'D:\\Programming\\Py33\\lib',
 'D:\\Programming\\Py33',
 'D:\\Programming\\Py33\\lib\\site-packages']
Server time:    Wed, 8 Jan …
Run Code Online (Sandbox Code Playgroud)

python django django-registration python-3.3 django-1.6

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

"TemplateSyntaxError:'humanize'不是一个有效的标签库:"在DJango中

在设置django-registration模块时,我遇到了一些麻烦.就渲染模板而言,一切正常.在尝试测试注册后,我遇到了这个错误.我在settings.py文件中有Django.contrib.humanize.任何帮助表示赞赏

python django django-registration

12
推荐指数
1
解决办法
8936
查看次数

django +使用django-registration以html发送电子邮件

即时通讯使用django-registration,一切都很好,确认电子邮件是以纯文本形式发送的,但我知道我已修复并正在发送html,但我有一个垃圾问题...... html代码显示:

<a href="http://www.example.com/accounts/activate/46656b86eefc490baf4170134429d83068642139/">http://www. example.com/accounts/activate/46656b86eefc490baf4170134429d83068642139/</a>
Run Code Online (Sandbox Code Playgroud)

我不需要像...那样显示HTML代码

任何的想法?

谢谢

email django django-templates django-registration

11
推荐指数
2
解决办法
9914
查看次数

Django - Ajax模式登录/注册

我有一个项目,我需要为未经过身份验证的用户弹出模式窗口.

此模式将允许直接登录创建帐户.

所以它将包含两种形式:

  • django.contrib.auth.forms.AuthenticationForm
  • registration.forms.RegistrationForm

模态选项卡表单

这是我的观点,以获得两种形式:

def ajax_registration(request):
    obj = {
        'login_form': AuthenticationForm(),
        'registration_form': RegistrationForm(),
    }
    return render(request, 'common/ajax_registration.html', obj)
Run Code Online (Sandbox Code Playgroud)

我的模板显示表格标签

<ul class="nav nav-tabs">
  <li><a href="#tab1" data-toggle="tab">{% trans 'Login' %}</a></li>
  <li><a href="#tab2" data-toggle="tab">{% trans 'Registration' %}</a></li>
</ul>
<div class="tab-content">
  <div class="tab-pane active" id="tab1">
    {{ login_form|bootstrap }}
  </div>
  <div class="tab-pane" id="tab2">
    {{ registration_form|bootstrap }}
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

问题是:由于我使用AJAX来显示这个模式,我怎样才能确认所选的形式,最好使用已经书面django-registrations registerdjango.contrib.auth login看法?

django ajax django-templates django-registration twitter-bootstrap

11
推荐指数
1
解决办法
1万
查看次数

django-registration app和Django 1.5自定义用户模型

我使用django-registration app和Django 1.5.如何创建(django中的新)自定义用户模型并在注册期间保存此数据(请注意我使用的是django-registration):

class CustomProfile(models.Model):
    user = models.ForeignKey(User)
    name = models.CharField(max_length=255)
    bank = models.CharField(max_length=255)
    address = models.CharField(max_length=255)
Run Code Online (Sandbox Code Playgroud)

python django django-registration

11
推荐指数
1
解决办法
5024
查看次数

与django 1.7的Django注册兼容性问题

我一直在使用[django-registration](https://bitbucket.org/ubernostrum/django-registration),现在我已经开始使用django 1.7b1了,这是我收到下面复制的错误的错误.它是从django-registration中提出的models.py:

try:
    from django.contrib.auth import get_user_model
    User = get_user_model()
except ImportError:
    from django.contrib.auth.models import User
Run Code Online (Sandbox Code Playgroud)

它似乎正在被提出,因为get_user_model()在app注册表准备好之前被调用.我不确定这是否是兼容性问题,如果是,是否有一个简单的解决方法?如果没有,你能帮我辨别我做错了吗?

RuntimeError: App registry isn't ready yet.
File "/Users/nima/pe-dev/manage.py", line 9, in <module>
  execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/Django-1.7b1-py2.7.egg/django/core/management/__init__.py", line 427, in execute_from_command_line
  utility.execute()
File "/Library/Python/2.7/site-packages/Django-1.7b1-py2.7.egg/django/core/management/__init__.py", line 391, in execute
  django.setup()
File "/Library/Python/2.7/site-packages/Django-1.7b1-py2.7.egg/django/__init__.py", line 21, in setup
  apps.populate(settings.INSTALLED_APPS)
File "/Library/Python/2.7/site-packages/Django-1.7b1-py2.7.egg/django/apps/registry.py", line 106, in populate
  app_config.import_models(all_models)
File "/Library/Python/2.7/site-packages/Django-1.7b1-py2.7.egg/django/apps/config.py", line 190, in import_models
  self.models_module = import_module(models_module_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
  __import__(name) …
Run Code Online (Sandbox Code Playgroud)

django django-registration django-1.7

11
推荐指数
1
解决办法
5937
查看次数

如何在注册时使django-rest-framework-jwt返回令牌?

我有一个基本的django休息服务,其中

  1. 注册一个人和
  2. 更新他的密码.

我想在它上面添加jwt身份验证.如果我按照教程操作,我需要在项目的urls.py中添加一个名为"api-token-auth"的新URL.但是,我不想添加这个新的url,并希望我的注册调用发送一个令牌作为响应.

这是我的代码:

serializers.py

class UserSerializer(serializers.HyperlinkedModelSerializer):
    def create(self, validated_data):
        user = User(
            username=validated_data['username']
        )
        user.set_password(validated_data['password'])
        user.save()
        return user

    def update(self, instance, validated_data):
        instance.set_password(validated_data['password'])
        instance.save()
        return instance

    class Meta:
        model = User
        fields = ('url', 'username', 'password')
        lookup_field = 'username'
        write_only_fields = ('password',)
Run Code Online (Sandbox Code Playgroud)

views.py

class UserViewSet(viewsets.ModelViewSet):
    """
    API endpoint that allows users to be viewed or edited.
    """
    queryset = User.objects.exclude(is_superuser=1)
    serializer_class = UserSerializer
    lookup_field = 'username'
Run Code Online (Sandbox Code Playgroud)
  1. 要做到这一点应该怎么做?我应该在序列化程序的create方法中调用api-auth-token吗?
  2. django-rest-framework-jwt如何处理多个身份验证令牌并正确识别哪个令牌属于哪个用户?特别是当它不在db中存储令牌时.
  3. 如何使用此身份验证机制限制用户仅查看/更新/删除其用户?
  4. 我如何使用此身份验证机制来执行任何操作.例如,如果用户想要将他的名字写入/tmp/abcd.txt.如何确保只有经过身份验证的用户才能这样做?
  5. 这种方法是否存在潜在的漏洞.如果我的应用程序要存储大量分类数据,我应该使用相同的代码吗?

python authentication django django-registration django-rest-auth

10
推荐指数
2
解决办法
9343
查看次数