我想使用自定义模型扩展我的用户配置文件。不幸的是,每当我访问配置文件所在的页面时,我都会收到'tuple‘对象没有属性'update’
我自己也试着绕开这件事,但2,5小时后,我确实觉得自己被困住了。
有人能指点我吗?
型号:
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class Skills(models.Model):
description = models.CharField(max_length=3000)
每当我试图以登录用户身份更改密码时,都会收到一个attributeError。我正在使用Django的内置PasswordChangeForm。有人能帮忙吗?
这是我的views.py:
from django.shortcuts import render, redirect
from accounts.forms import (
RegistrationForm,
EditProfileForm
)
from django.contrib.auth.models import User
from django.contrib.auth.forms import (
#Reverse for 'user_profile_view' with arguments '(u'Emmanuel',)' and keyword arguments '{}' not found. 0 pattern(s) tried: [] :
#project/urls.py:
from django.conf.urls import url, include
from django.contrib import admin
from django.conf impor
我是Django新手,用Django 1.11编写了一个应用程序。
我想要创建一个Profile update页面。
我创建了一个应用程序accounts来管理所有与配置文件相关的活动,并创建了一个类。
from django.contrib.auth.models import User
# Create your views here.
from django.views.generic import TemplateView, UpdateView
class ProfileView(TemplateView):
template_name = 'accounts/
当我添加一个表单来添加电话号码时,一切都正常工作。
然而,当我为full_name添加字段时,我得到了这个错误:
ViewDoesNotExist at /phone/ Could not import accounts.views.add_phone. View does not exist in module accounts.views..
代码如下:
views.py
class PhoneForm(forms.Form):
phone = forms.IntegerField()
full_name = forms.Charfield()
def add_pho
我正在制作一个钱包应用程序,所以如果有人去添加钱,然后按下submit,就必须将钱添加到他们的钱包中,但是在提交之后有一个错误:
AttributeError at /add_money/ 'unicode' object has no attribute 'user'
为了更好地了解行动流程,我设置了一些检查站:
Request <WSGIRequest: GET '/add_money/'>
Request j <WSGIRequest: GET '/add_money/'>
[15/Dec/2016
我正在尝试扩展User模型以创建一个Profile模型。下面的代码成功地显示了一个表单,其中包含我指定为location和bio的附加字段。但是当我提交表单时,只有原始的username、first_name、last_name、email和password字段存储在的数据库中,而我的自定义字段没有存储在我添加到admin的配置文件部分中。我还得到了以下错误:
IntegrityError at /accounts/register/
NOT NULL constraint failed: accounts_profile.user_id
Request Method: POST
Reques
我有以下带有内部联接的sql命令:
SqlCommand cmd = new SqlCommand(@"SELECT c.comment_Id, c.date, c.comment, c.rating, a.registration_Date, a.username, a.email, a.profile_Image FROM News_comments c INNER JOIN News_accounts a ON c.account_Id=a.account_Id WHERE c.news_Id = @news_Id", conn);
cmd.Parameters.Add(
我的forms.py文件
class CreateUserForm(UserCreationForm):
phone=PhoneNumberField()
class Meta:
model = User
fields = ['username', 'email', 'password1', 'password2', 'phone']
widgets={
'username':forms.TextInput(at
你能帮我处理Django和定制的用户模型吗?我是Django世界的新手,所以我开始学习最新版本1.7。在我的项目中,我使用django-allauth包,我希望在来自contrib.auth的标准用户类与我的自定义模型“用户”之间创建contrib.auth关系。
#models.py
import datetime
from django.db import models
from django.contrib.auth.models import User
class Profile(models.Model):
user=models.OneToOneField(User
没有错误,但表单没有保存到数据库中。否则,可以从django admin添加数据。
urls和重定向也很好,我可以打开表单、编辑/放置数据并点击submit,但是数据库没有反映。
models.py
from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
class RPAS(models.Model):
user = models.OneToOneField(User)
manufacture
我有一个简单的视图,它应该检查是否有post数据,如果是这样的话,使用UserChangeForm**.更新用户数据。否则获取用户的表单数据并显示。**
问题: AttributeError at /profile/AnonymousUser对象没有属性“_meta”
我想可能是edit_profile视图中的这一行
# Handles the get request - if no post info is submitted then get the form and display it on the edit profile page.
else:
我试图使用这里提供的示例构建一个简单的django论坛:
当我试图打开本地主机/论坛/
TemplateSyntaxError at /accounts/login/
Could not parse the remainder: ':index' from 'admin:index'
Error during template rendering
In template /Documents/Projects/dbe/forum/templates/forum/fbase.html, error at line 52
Could not parse the
当我尝试从shell、manage.py或Django-Admin页面创建超级用户时,它引发的错误如下:
IntegrityError at /admin/auth/user/add/
null value in column "link_karma" violates not-null constraint
这是我的models.py用户部分
class User_Profile(models.Model):
user = models.OneToOneField(User)
link_karma = models.IntegerField()
co
当我想让注册错误出现在Manager是不可用的时候,我的代码出现了问题;'auth.User‘被替换为'users.User’,我尝试了一个与Manager相同的解决方案--与Manager是不可用的;'auth.User‘已经被替换为'members.customer’,但是它们都要求替换User = User = get_user_model(),但是我的代码中没有使用任何用户,或者我不知道我在哪里使用它,我是django、python、js等的新手,所以如果我的问题愚蠢到原谅我的话。
错误:
AttributeError at /accounts/sig
我是Django的新手,请原谅代码或逻辑上的任何愚蠢错误,
简介:,我正试图在Django中创建一个用户跟随者模型。在这些站点上,用户可以跟踪和取消跟踪其他用户
错误:我已经为我的跟随/取消跟踪做了models,我也做了要得到这个错误的views
AttributeError at /accounts/admin/follow/
Cannot use add() on a ManyToManyField which specifies an intermediary model. Use accounts.Contact's Manager instead.
obj.follower
我想在url /account/profile中显示用户配置文件。我有一个基于细节类的视图,
class UserDetail(generic.DetailView):
model = User
slug_field = 'username'
slug_url_kwarg = 'username'
template_name = 'myuser/user_detail.html'
我有个错误:
AttributeError at /accounts/profile/
Generic detail View Use