django-1.4

How to use the built-in 'password_reset' view in Django?

大兔子大兔子 提交于 2019-11-29 19:22:39
问题 I have set the following entry in the urls.py (r'^password_reset/$', 'django.contrib.auth.views.password_reset'), but once I go to http://127.0.0.1:8000/password_reset/ I get the error message: NoReverseMatch at /password_reset/ Reverse for 'django.contrib.auth.views.password_reset_done' with arguments '()' and keyword arguments '{}' not found. I was expecting password_reset_done view also to be coming out of the box. So what am I supposed to do at this stage? UPDATE After trying Blair's

Django forms.DateInput does not apply the attributes given in attrs field

自闭症网瘾萝莉.ら 提交于 2019-11-29 14:09:01
问题 Placeholder, class not getting set when tried to apply through the django's attrs specifier for forms.DateInput The form is a ModelForm. And according to the docs Takes same arguments as TextInput, with one more optional argument: Here is the code : widgets = { 'my_date_field': forms.DateInput(format=('%d-%m-%Y'), attrs={'class':'myDateClass', 'placeholder':'Select a date'} ) } The same is applied for a forms.TextInput and it works just fine. What am I missing here? Just anybody wants a full

'admin' is not a registered namespace in Django 1.4

落爺英雄遲暮 提交于 2019-11-29 11:24:17
问题 I'm attempting to upgrade quite a large Django project to the newly released Django 1.4, and I'm having some issues when running python manage.py test . Lots of the internal tests which passed in Django 1.3 are now failing, with really odd messages that I can't seem to fix. One that appears the most is: NoReverseMatch: u'admin' is not a registered namespace This is raised for the django.contrib.auth tests for password changing in particular (one of which is test_password_change_fails_with

Django template conditional variable assignment

回眸只為那壹抹淺笑 提交于 2019-11-29 09:19:22
I want to assign a variable do different values depending on if a variable exists, is this possible? My non working example might make it clearer: {% if username %} {% with menu_user=username %} {% elif recent_users %} {% with sorted_users=recent_users|dictsortreversed:"timestamp" %} {% with menu_user=sorted_users.0.username %} {% endif %} {% if menu_user %} <div id="menu"> <ul> <li><a href="/user/{{ menu_user|urlencode }}">Profile</a></li> <li><a href="/user/{{ menu_user|urlencode }}/products/">Products</a></li> </ul> </div> {% endif %} {% if recent_users %} {% endwith %} {% endif %} {%

How to bind multiple reusable Django apps together?

房东的猫 提交于 2019-11-28 17:45:18
问题 I try my best to write reusable Django apps. Now I'm puzzled how to put them all together to get the final project. Here is an example of what I mean: I have a picture app that stores, resizes and displays images. Also I have a weblog app that stores, edits and displays texts. Now I want to combine these two to show blog posts with images. To do that I could put foreign key fields in the blog to point at pictures. But then the blog could not be used without the picture app. Also I could

Django template conditional variable assignment

旧城冷巷雨未停 提交于 2019-11-28 02:45:28
问题 I want to assign a variable do different values depending on if a variable exists, is this possible? My non working example might make it clearer: {% if username %} {% with menu_user=username %} {% elif recent_users %} {% with sorted_users=recent_users|dictsortreversed:"timestamp" %} {% with menu_user=sorted_users.0.username %} {% endif %} {% if menu_user %} <div id="menu"> <ul> <li><a href="/user/{{ menu_user|urlencode }}">Profile</a></li> <li><a href="/user/{{ menu_user|urlencode }}

How to set up Django models with two types of users with very different attributes

本小妞迷上赌 提交于 2019-11-27 16:44:33
问题 Note: I've since asked this question again given the updates to Django's user model since version 1.5. I'm rebuilding and making improvements to an already existing Django site and moving it over from Webfaction to Heroku, and from Amazon's SimpleDB to Heroku Postgres (though testing locally on Sqllite3 when developing). A lot of what I'm doing is moving over to use built-in Django functionality, like the Django admin, user authentication, etc. Conceptually, the site has two kinds of users: