Python django.contrib.auth.forms 模块,UserChangeForm() 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用django.contrib.auth.forms.UserChangeForm()

项目:Sermul    作者:CHOQUERC    | 项目源码 | 文件源码
def EditUser(request, slug=None):
    """
    Editar usuario de forma simple.
    """
    user = request.user
    if request.method == 'POST':
        form = UserChangeForm(request.POST, instance=user)
        if form.is_valid():
            #Actualizar el objeto
            user = form.save()
            messages.success(request, 'Usuario actualizado exitosamente.', extra_tags='html_dante')
            return HttpResponseRedirect(reverse('home:listar_usuarios'))
    else:
        form = UserChangeForm(instance=user)
    context = {
        'form': form,
    }
    return render(request, 'home/user_change.html', context)
项目:no-design-slack-clone    作者:metsavaht    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        super(UserChangeForm, self).__init__(*args, **kwargs)

        if 'username' in self.fields:
            del self.fields['username']
项目:django-project-template    作者:thorgate    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        super(UserChangeForm, self).__init__(*args, **kwargs)

        if 'username' in self.fields:
            del self.fields['username']
项目:djangocms-onepage-example    作者:thorgate    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        super(UserChangeForm, self).__init__(*args, **kwargs)

        if 'username' in self.fields:
            del self.fields['username']