CSRF verification fails when using nginx reverse proxy cache

2011-04-18 Thread Sævar Öfjörð
Hi I'm considering using nginx as a caching reverse-proxy to improve my site's performance. When I have the proxy turned on, the CSRF verification does not work (at least not for contrib.auth login view). Probably because the csrf_token in the form is cached and invalid. I've googled this without

Re: Django Form ChoiceField, initial not working

2010-12-11 Thread Sævar Öfjörð
I think you should provide your choices in the form field, not when creating an instance of the form. The form would then be something like this: class StoreLocationHoursForm(BForm): sl_list= [('-', 'Choose Location'), (u'Super City', u'901 PHILADELPHIA STREET')] location = forms.ChoiceFie

Re: Executing ssh scripts with django

2010-11-02 Thread Sævar Öfjörð
> Would you execute the save function through celery? Is it safe? or maybe if > save() is executed asynchronously it can cause some unexpected behavior? You could use signals to trigger execution of celery tasks, e.g. the post_save signal: http://docs.djangoproject.com/en/dev/ref/signals/#django.d

Re: Reponse code for a require_XHR decorator?

2010-10-12 Thread Sævar Öfjörð
400 Bad request indicates that the server did not understand the request and that the client should not repeat it without modification. I'd say it doesn't really matter what status code you use internally, but 403 Forbidden is probably more expressive for this situation. 403 indicates that the serv

Re: reverse url of admin list

2010-10-12 Thread Sævar Öfjörð
It's called 'changelist' So you should call reverse('admin:invoice_invoice_changelist') -Sævar On Oct 12, 1:39 pm, Marc Aymerich wrote: > I'm trying to find out what is the reverse url sentence for the "admin list" > of a specific model of an app. Suppose that we have an app called 'invoice' >

Re: django-facebook

2010-10-10 Thread Sævar Öfjörð
I'm using Django Socialregistration for this purpose. http://github.com/flashingpumpkin/django-socialregistration If the user is already logged in and clicks the facebook button, the existing account is simply linked to the FB account. New users have the option to set up a username. - Sævar On O

Re: change ordering of objects/rows on change list view on admin

2010-09-19 Thread Sævar Öfjörð
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.ordering On Sep 19, 10:56 pm, rahul jain wrote: > Hi there !, > > How to change ordering of objects/rows on change list view on admin ? > > --Rahul -- You received this message because you are subscribed to

Re: Facebook Comments

2010-09-11 Thread Sævar Öfjörð
Where exactly are you expecting them to be posted? I think the Facebook Comments plugin is only supposed to provide a comment feature on individual pages so that you don't have to write your own, it's not an external comment box for your FB page. - Sævar On Sep 10, 5:41 pm, Bobby Roberts wrote:

Re: authentication through http authorization header

2010-08-29 Thread Sævar Öfjörð
I guess you would have to subclass both RemoteUserMiddleware and RemoteUserBackend. I'm not sure if this will work, but at least it's one idea. In your custom RemoteUserMiddleware you would have to set the header property to HTTP_AUTHORIZATION so that Django knows where to find the username.

Re: readonly form field

2010-08-25 Thread Sævar Öfjörð
You could use a widget http://stackoverflow.com/questions/1827526/django-creating-a-form-field-thats-read-only-using-widgets Best regards, Sævar On Aug 24, 7:02 pm, Rodrigo Lombardo wrote: > Hi, > > I'm new to Django and I'm learning a lot reading the docs and some books. > I'm trying to genera

Re: accessing a dictionary in template

2010-08-09 Thread Sævar Öfjörð
I take it that you absolutely need to dynamically access the values through generated keys? Not just a regular for loop? {% for var in some_mapping %} {{ var }} {% endfor %} - Sævar On Aug 9, 8:56 pm, owidjaya wrote: > in php i can do this > > $some_mapping = array( "var1" : content_var1, >

Re: Many to many ajax widget for admin

2010-08-02 Thread Sævar Öfjörð
On Jul 27, 5:24 am, ringemup wrote: > You might want to check out grappelli and its Related Lookups feature: > > http://code.google.com/p/django-grappelli/ > > On Jul 26, 4:30 pm, Sævar Öfjörð wrote: > > > > > Hi > > > I have some models (Song and Auth

Re: Django INNER JOIN

2010-07-28 Thread Sævar Öfjörð
It would help if you submitted your models - Sævar On Jul 28, 2:29 pm, kostia wrote: > I have a model Favourite with fields User, Project, Date, what means > that some user put some project as favourite on some date. I take all > favourites filtered by this user and I want to INNER JOIN that info

Re: implementing next and previous of the object

2010-07-28 Thread Sævar Öfjörð
It's probably best to do this in a custom Manager. This code is based on this answer: http://markmail.org/message/kwwuskco4gilej2w You get the idea class GetPrevNextManager(models.Manager): def get_next_by_id(self, object): qs = self.filter(id__gt=object.id) if qs.count() > 0:

Many to many ajax widget for admin

2010-07-26 Thread Sævar Öfjörð
Hi I have some models (Song and Author) that are related through an intermediary model (Authorship) like this: class Song(models.Model) authors = models.ManyToManyField('Author', through='Authorship') class Author(models.Model) name = models.CharField(max_length=255) class Authorship(mo

Re: how do I add a custom button (url) to the admin add/change page

2010-07-12 Thread Sævar Öfjörð
You might want to take a look at overriding admin templates: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates - Sævar On Jul 12, 8:38 am, gondor wrote: > I'm trying to add a simple button to a specific add/change page.  This > button takes the user to another ur

Re: Log errors to file

2010-07-09 Thread Sævar Öfjörð
That's something that would be nice to have as a snippet on djangosnippets.org! On Jul 8, 11:34 am, "euan.godd...@googlemail.com" wrote: > I have created a decorator for Django views which handles AJAX > tracebacks and sends the traceback back to the AJAX application as > JSON, e.g. > > {'status'

Re: News on every page

2010-07-09 Thread Sævar Öfjörð
That depends entirely on your cache configuration! Caching in django: http://docs.djangoproject.com/en/dev/topics/cache/ Automatic caching modules that rely on memcached exist, like Johnny Cache (http://packages.python.org/johnny-cache/) and Django Cache Machine (http://github.com/jbalogh/django-c

Re: How to commit ManyToManyField with ModelForm

2010-07-09 Thread Sævar Öfjörð
Have you tried resetting your database and syncing it again? If there are columns missing it sounds like you added them after you did a manage.py syncdb Django will not alter your tables after they have been created. More info on this here: http://docs.djangoproject.com/en/dev/ref/django-admin/?fro

Re: cached template loader

2010-07-06 Thread Sævar Öfjörð
I've also tried passing this through django.shortcuts.render_to_response, but I get the same error. - Sævar On Jul 6, 2:41 pm, Sævar Öfjörð wrote: > Hi, I've been using the default template loaders and it works fine. > Now I want to add the cached template loader, but I get a

cached template loader

2010-07-06 Thread Sævar Öfjörð
Hi, I've been using the default template loaders and it works fine. Now I want to add the cached template loader, but I get an error. I'm using a wrapper function to return responses that include the request in the context, like this: # file helpers/helpers.py from django.template import RequestC

Re: django changes some chracters in on my website

2010-07-05 Thread Sævar Öfjörð
If you are storing un-escaped HTML in your database, you must mark it as safe when you use it in your templates. You can use the safe filter for that: {{ some_variable|safe }} More information: http://docs.djangoproject.com/en/dev/ref/templates/builtins/ - Sævar On Jul 3, 7:31 pm, davidgp wrot