AUTH_USER_MODEL在EDIT3中解决了错误.密码仍然无法通过表单保存用户创建.
我正在使用Django 1.5来玩新的用户覆盖/扩展功能,而我无法通过我的注册表单注册新用户 - 只能通过管理员注册.通过注册表注册时,我收到以下错误:
Manager isn't available; User has been swapped for 'poker.PokerUser'
models.py:
class PokerUser(AbstractUser):
poker_relate = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True)
token = models.EmailField()
USER_CHOICES = (
('1', 'Staker'),
('2', 'Horse')
)
user_type = models.CharField(choices=USER_CHOICES, max_length=10)
username1 = models.CharField(null=True, blank=True, max_length=40)
username2 = models.CharField(null=True, blank=True, max_length=40)
username3 = models.CharField(null=True, blank=True, max_length=40)
username4 = models.CharField(null=True, blank=True, max_length=40)
username5 = models.CharField(null=True, blank=True, max_length=40)
Run Code Online (Sandbox Code Playgroud)
PokerUserForm 模型:
class PokerUserForm(UserCreationForm):
class Meta:
model = PokerUser
fields = ('username','password1','password2','email','user_type','token','username1','username2','username3','username4','username5',)
Run Code Online (Sandbox Code Playgroud)
我试图改变模型中的PokerUserForm模型使用get_user_model()而不是通过设置 …
我已经安装了Elastic Beanstalk应用程序和环境.我刚刚在Windows上下载了Dev Tools CLI/eb,并希望eb用于推送到所述环境.
如果我使用eb init,我必须创建一个新的EB应用程序和环境.
如何将git repo初始化为现有的EB应用程序和环境?
是否可以path动态使用该功能?用变量作为参数?
{{ path(nav.url, { nav.param_name : nav.param_value }) }}
因为如果我尝试使用我得到的代码:
A hash key must be followed by a colon (:).
Unexpected token "punctuation" of value "."
("punctuation" expected with value ":")
Run Code Online (Sandbox Code Playgroud)
我知道通过'硬编码' param_name将会工作...像这样:
{{ path('nav.url', { 'id' : nav.param_value }) }}
但是我需要动态传递3值
我熟悉etree strip_tags和strip_elements方法,但我正在寻找一种直接的剥离标签(并留下其内容)只包含特定属性/值的方法.
例如:我想从树(l)中剥离具有属性/值的所有span或div标记(或其他元素)(保留元素的内容就像那样).与此同时,那些相同的元素不具备应保持不变.xhtmclass='myclass'strip_tagsclass='myclass'
相反:我想要一种剥去所有"裸体" spans或divs树木的方法.仅表示那些完全没有属性的spans/ divs(或任何其他元素).留下那些具有属性(任何)的相同元素不变.
我觉得我错过了一些明显的东西,但是我一直在寻找没有任何运气的时间.
我一直试图让django-allauth工作几天,我终于知道发生了什么.
base.html该应用程序不会加载使用django-allauth安装的模板,而是加载base.html我用于其余网站的文件.
我怎么告诉django-allauth在virtualenv/lib/python2.7/sitepackages/django-allauth目录而不是我的project/template目录中使用base.html模板?
我有一个搜索视图,允许用户搜索他们的记事卡,然后一次显示分页 6 的结果。
我在所有其他视图中使用分页并且它工作正常。但是,当将其与查询一起使用时,它会显示前 6 个结果,显示“第 1 页,共 2 页”和下一个按钮,但当您单击“下一步”时,您找不到任何结果。
我已将“*”查询设置为搜索全部,当我搜索该查询时,第一个请求调用是:
http://127.0.0.1:8000/search/?q=*
当我点击下一步时,调用的是:
http://127.0.0.1:8000/search/?page=2
搜索网址为:
url(r'^search/', 'notecard.search.views.search', name="search"),
搜索视图是:
@login_required(login_url='/auth/login/')
def search(request):
query = request.GET.get('q', '')
results = []
notecard_list = []
if query:
if query == "*":
results = Notecard.objects.filter(section__semester__user=request.user)
else:
results = Notecard.objects.filter(Q(section__semester__user=request.user), Q(notecard_body__icontains=query)|Q(notecard_name__icontains=query))
paginator = Paginator(results, 6)
try:
page = int(request.GET.get('page', '1'))
except ValueError:
page = 1
try:
notecard_list = paginator.page(page)
except (EmptyPage, InvalidPage):
notecard_list = paginator.page(paginator.num_pages)
return list_detail.object_list(
request,
queryset = Notecard.objects.filter(section__semester__user=request.user),
template_name = "notecards/search.html",
template_object_name …Run Code Online (Sandbox Code Playgroud) 在Rails 3.2.11应用程序中,我有以下路由,以便将www重定向到非www:
constraints(:host => /www.foo.com/) do
root :to => redirect("http://foo.com")
match '/*path', :to => redirect {|params| "http://foo.com/#{params[:path]}"}
end
Run Code Online (Sandbox Code Playgroud)
无论如何,rspec会抛出以下警告:
DEPRECATION WARNING: redirect blocks with arity of 1 are deprecated. Your block must take 2 parameters: the environment, and a request object. (called from block (2 levels) in <top (required)> at /foo/config/routes.rb:6)
Run Code Online (Sandbox Code Playgroud)
我无法在谷歌上找到一些东西所以我想问是否有人知道如何摆脱这个警告.
谢谢
请帮助我在短时间内学习google-apps-script。我想通过从电子表格中存储的数据生成的url从远程站点下载文件。
例如,我有2个参数:
Cell1 = val1, val2, ... valN
Cell2 = val21, val22, ... val2N
Run Code Online (Sandbox Code Playgroud)
我将字符串从单元格数据拆分为数组,然后生成URL。例如:http://mysite.com/files/file.val1.val22.zip
比我需要从此链接下载文件...
我可以自动执行此过程吗?
我在使用NUnit的xamarin工作室中编写UnitTests(没有与设备和东西进行集成测试)的monotouch和monodroid.
这很好用,除了我没有看到任何日志输出创建的问题Debug.WriteLine.
有人知道如何在xamarin工作室中激活它吗?
谢谢!
我有一个现有的Django项目,我刚刚添加到南方.
manage.py schemamigration app_name当地跑manage.py migrate app_name --fake当地跑manage.py schemamigration app_name了herokumanage.py migrate app_name了heroku然后我收到这个:
$ heroku run python notecard/manage.py migrate notecards
Running python notecard/manage.py migrate notecards attached to terminal... up, run.1
Running migrations for notecards:
- Migrating forwards to 0005_initial.
> notecards:0003_initial
Traceback (most recent call last):
File "notecard/manage.py", line 14, in <module>
execute_manager(settings)
File "/app/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/app/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv) …Run Code Online (Sandbox Code Playgroud) python ×5
django ×4
amazon ×1
django-1.5 ×1
google-apps ×1
heroku ×1
logging ×1
lxml ×1
nunit ×1
php ×1
symfony ×1
twig ×1
windows ×1
xamarin ×1
xamarin.ios ×1