django-1.4

Django 1.4 - Redirect to Non-HTTP urls

你。 提交于 2019-12-03 11:55:59
问题 We have a view which redirects to a Non-HTTP url scheme. Its used in an iOS app. But since we have upgraded to Django1.4 we are getting a crash when this redirect code is executed. It crashes with SuspeciousOperation at /myyrlscheme/ Unsafe redirect to URL with scheme appdev: Following is the code: if acode and acode.has_key('access_token'): if DOMAIN == 'dev.mywebsite.com': return HttpResponseRedirect('appdev://fbconnect?token=%s'%(acode['access_token'])) else: return HttpResponseRedirect(

{% url %} gives me NoReverseMatch error while reverse() returns the url just fine. Why?

纵然是瞬间 提交于 2019-12-03 03:15:44
I don't know if this SO question is of the same problem that I am about to describe, but it does share the same symptoms. Unfortunately, it still remains unresolved as I am writing. So here is my problem. I am trying to add James Bennett's django-registration app to my django project. I have pretty much finished configuring it to my needs - custom templates and urls. Just when I thought everything was good to go. I got NoReverseMatch error from using {% url 'testing' item_id=123 %} (I also tried using the view name, myapp.views.test , instead but no luck) in one of the custom templates

Django 1.4 - Redirect to Non-HTTP urls

☆樱花仙子☆ 提交于 2019-12-03 03:12:58
We have a view which redirects to a Non-HTTP url scheme. Its used in an iOS app. But since we have upgraded to Django1.4 we are getting a crash when this redirect code is executed. It crashes with SuspeciousOperation at /myyrlscheme/ Unsafe redirect to URL with scheme appdev: Following is the code: if acode and acode.has_key('access_token'): if DOMAIN == 'dev.mywebsite.com': return HttpResponseRedirect('appdev://fbconnect?token=%s'%(acode['access_token'])) else: return HttpResponseRedirect('app://fbconnect?token=%s'%(acode['access_token'])) I can understand why this crashes as

South + Django 1.4 Database error

可紊 提交于 2019-12-02 22:06:35
I have just installed my Django project on a new system, and installed Django 1.4. However when I try to run manage.py runserver or manage.py syncdb I get this error from South: Validating models... Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x1a67810>> Traceback (most recent call last): File "/home/saul/.virtualenvs/canada/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 91, in inner_run self.validate(display_num_errors=True) File "/home/saul/.virtualenvs

Django 1.4 admin static files without staticfiles app

吃可爱长大的小学妹 提交于 2019-12-02 17:36:56
问题 Django 1.4 release notes state: If you're implicitly relying on the path of the admin static files within Django's source code, you'll need to update that path. The files were moved from django/contrib/admin/media/ to django/contrib/admin/static/admin/. Could somebody explain how this is done exactly? Up to Django 1.3 we used ADMIN_MEDIA_PREFIX in settings.py, which is now deprecated. However, since we are developing all the time on our static files (js, css, ...), the staticfiles app is a

Django Signals to update a different model

微笑、不失礼 提交于 2019-12-02 13:20:02
问题 Say I have two models: class Product(models.Model): product = model.CharField() quantity = model.IntegerField() class sale(models.Model) product = models.ManyToManyField(Product) number_sold = model. IntegerField() When a sale is made, I'd like the product quantity to be updated. Are signals the best way of going about this? I was thinking about having sale admit a post_save signal when an object is created or updated. If updated, I would have to know the old and the new values to adjust the

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

送分小仙女□ 提交于 2019-11-30 14:27:47
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 solution, I got a step closer. (r'^password_reset_done/$', 'django.contrib.auth.views.password_reset_done')

'admin' is not a registered namespace in Django 1.4

最后都变了- 提交于 2019-11-30 11:16:36
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_mismatched_passwords (django.contrib.auth.tests.views.ChangePasswordTest) . The strange thing is, the

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

别等时光非礼了梦想. 提交于 2019-11-30 09:15:17
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 class code : class trademark_form(ModelForm): my_date_field = DateField(input_formats=['%d-%m-%Y'])

How to bind multiple reusable Django apps together?

二次信任 提交于 2019-11-29 21:48:26
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 create a third app, which is responsible to connect both. What is the 'best practice' way of doing it ? EDIT