Re: Install PIL on a shared hosting

2009-06-07 Thread Phui Hock
On Jun 7, 11:55 pm, Alex Gaynor wrote: > On Sun, Jun 7, 2009 at 9:23 AM, simonecare...@gmail.com < > > > > simonecare...@gmail.com> wrote: > > > I'm on SITE5. > > > I've just created a symbolic link to PIL from my PYTHON PATH. > > > I can import PIL module, but now I get this error: > > > The _im

Re: Problem with Image field saving

2009-12-04 Thread Phui Hock
You should retrieve file from request.FILES, not request.POST. On Dec 4, 2:57 pm, guptha wrote: > Hi group , > I am getting error like "Key 'fathers_photo' not found in > > forms.py > class FatherProfileForm(forms.Form): >     fathers_photo = forms.ImageField(required=False) >     fathers_mobile

How to use debugger from doctest

2009-12-14 Thread Phui Hock
Suppose I have the following in app 'app'. from django.db import models class Test(models.Model): """ >>> v = "Hello, world!" >>> import pdb; pdb.set_trace() """ Running manage.py test app will drop me to an interactive debugger mode but no output. How to execute the usual p, j, s

Re: How to use debugger from doctest

2009-12-15 Thread Phui Hock
n xterm, and drive > >> pdb from there, > >> without fiddling with stdin, stdout, and stderr at all.  (This would > >> definitely be a cool > >> addition to pdb, if it's not already there.) > > >> And, of course, you can always sprinkle in code to ap

Re: Filter (AND excluding empty values)

2009-12-15 Thread Phui Hock
I suppose you can do something like: Property.objects.filter( city=t, Q(category__isnull=True) | Q(category=c), Q (status__isnull=True) | Q(status=s) ) On Dec 16, 9:17 am, Osiaq wrote: > Yes, this one is working properly. > Actually I can use i.e > > properties = Property.objects.filter( Q(city

Re: Filter (AND excluding empty values)

2009-12-15 Thread Phui Hock
I see. I think this is probably you are looking for: params = ['city', 'category', 'status'] kwargs = dict([(p, request.GET.get(p)) for p in params if request.GET.get(p)]) # use just the request params whose value is not empty string Property.objects.filter(**kwargs) On Dec 16, 12:40 pm, Osiaq w

Reversing URL with unnamed capturing groups

2010-07-10 Thread Phui Hock
Hi, It seems that if I split a URL with unnamed capturing groups into different urls.py files, urlresolvers.reverse(..) doesn't work as expected. For example: --- root urls.py --- (r'^foo/(.*)/', include('foo.urls')) --- foo/urls.py --- url('^(.*)/$', blackhole, name='foo_1') When I do urlresolv

Multi-table inheritance, post_save and fixtures

2010-04-08 Thread Phui Hock
Given the following block of code: --- models.py --- from django.db import models from django.db.models.signals import post_save class Animal(models.Model): category = models.CharField(max_length=20) class Dog(Animal): color = models.CharField(max_length=10) def echo_category(sender, **k

Re: Multi-table inheritance, post_save and fixtures

2010-04-08 Thread Phui Hock
>> from animal.models import Dog >>> Dog.objects.get(pk=1).category u'omnivore' On Apr 8, 7:14 pm, Matthias Kestenholz wrote: > On Thu, Apr 8, 2010 at 1:04 PM, Phui Hock wrote: > > Given the following block of code: > > --- models.py --- > >

Re: Django password reset modification

2011-05-05 Thread Phui-Hock
On May 6, 4:22 am, Shawn Milochik wrote: > This is a bad idea for multiple reasons. Don't do it. Huh, care to explain, please? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com.

Best practices to secure admin site

2011-06-23 Thread Phui-Hock
Hi, This question has been asked a few times, but is there a general set of best practices one should follow to secure Django admin site? A quick check on some of the Django powered websites leave /admin/ open to public access, and some don't even use https for login form submission. Although only

Re: Best practices to secure admin site

2011-06-23 Thread Phui-Hock
> * Only allow HTTPS (to the admin, and perhaps to the entire site). > * Don't use "/admin/" -- I usually use a separate subdomain like > "backend.example.com", or sometimes just a different root (I often see > "nqzva" -- figuring out why is left as an exercise for the reader :). > * Limit access b

permission module for Django views

2011-03-04 Thread Phui Hock
Hi, I have just released an experimental django-pobject, an expressive and concise permission module for django views at goo.gl/L6h7D. It is inspired by Q object of django.db. It supports bitwise operators AND , OR , XOR and invert ' ~ ' for complex permission construction. For example, you can do