Re: Aggregate function in django

2007-05-17 Thread Brian Beck
On May 17, 7:47 am, Brij <[EMAIL PROTECTED]> wrote: > Please help me getting the django database api for this query which i > can use in the my view and send the object to my template to display > the result Hi, check out this snippet I posted that tries to make similar SQL like this reusable. Un

Multiple projects on one domain - anyone have a good solution?

2007-05-11 Thread Brian Beck
So usually when I need to do this I just do a bunch of trial and error in lighttpd and get stuff mostly working, but I've never been happy with it. I want to have a Django project 'mounted' at /rta and another at / crime, both at the same domain. Sadly lighttpd doesn't support URL rewriting insid

Re: Anything special needed in URLconf for tilde?

2007-04-10 Thread Brian Beck
On Apr 10, 8:31 pm, "Brian Beck" <[EMAIL PROTECTED]> wrote: > I'm not sure, but it might be that tildes aren't valid URL characters. > Web browsers have to violate the spec in order to support this thanks > to someone screwing up a long time ago... It might a

Re: Anything special needed in URLconf for tilde?

2007-04-10 Thread Brian Beck
On Apr 10, 8:10 pm, "ryan k" <[EMAIL PROTECTED]> wrote: > > Am I missing something simple? I'm not sure, but it might be that tildes aren't valid URL characters. Web browsers have to violate the spec in order to support this thanks to someone screwing up a long time ago... --~--~-~--~--

Re: Django/CAS/login_url and @permission_required

2007-02-23 Thread Brian Beck
On Feb 23, 5:31 pm, "Chris Green" <[EMAIL PROTECTED]> wrote: > What is happening in the CAS case, is it redirects to the CAS login > url, which says the user is authorized and redirects to this > particular login page and it repeats forever if the user does not have > authorized permissions. > > H

Re: Django as Single Sign-On?

2007-02-02 Thread Brian Beck
u're welcome to check out the code to see what needs to be done for such a task; it's mostly middleware stuff. Details are here: http:// blog.case.edu/bmb12/2006/12/cas_for_django_part_2 Good luck, -- Brian Beck Adventurer of the First Order --~--~-~--~~~---~

Re: Passing values from Django to client-side JavaScript

2007-01-19 Thread Brian Beck
The JSON method mentioned above should work fine. Two methods that might be less fragile than code generation: - Hidden form inputs. Less fragile because the 'escape' filter should allow you to safely dump data into attribute values in your template, I think. Then use form.elements or MochiKit'

Re: Please help me use "views.django.views.static"

2007-01-13 Thread Brian Beck
Hi, I make using static.serve a little cleaner like so: In settings.py: STATIC_OPTIONS = {'document_root': MEDIA_ROOT, 'show_indexes': True} In urls.py: from django.conf import settings ... (r'^static/(?P.*)$', 'django.views.static.serve', settings.STATIC_OPTIONS), (change 'static/' above to

Re: a candidate for a custom decorator?

2007-01-11 Thread Brian Beck
I think your problem is the return values. args is a tuple and request should be there instead. In both of your decorators, return fn(request, *args, **kwargs) instead of fn(args, kwargs). --~--~-~--~~~---~--~~ You received this message because you are subscribed

Re: Empty related sets = Page not found?

2007-01-11 Thread Brian Beck
John Matthew wrote: > Thank you for the reply. No problem. :) --~--~-~--~~~---~--~~ 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 To unsubscribe

Re: Empty related sets = Page not found?

2007-01-10 Thread Brian Beck
Hi, object_list takes an allow_empty argument, try settings it to True. >From the docs: allow_empty: A boolean specifying whether to display the page if no objects are available. If this is False and no objects are available, the view will raise a 404 instead of displaying an empty page. By defa

Re: sorting the results of a queryset

2007-01-10 Thread Brian Beck
ry order as far as I know (I'm not sure how that could work). But if get_absolute_url() just returns 'http://whatever/categories/' + self.name for example, it may make sense to just do Category.objects.order_by('name').filter(...). -- Brian Beck Adventurer of the First Order

Re: sorting the results of a queryset

2007-01-09 Thread Brian Beck
Robert Slotboom wrote: > > sorted(Category.objects.all(), key=Category.get_absolute_url) > > This is a very nice approach! > Although, shouldn't these "get_absolute_url" calls be followed by () ? Nope! Python will call it for you. The good thing is it will only call it once per item instead of on

Re: sorting the results of a queryset

2007-01-09 Thread Brian Beck
ll(), key=Category.get_absolute_url) Then Python will call the method for you (and maybe cache the result for further comparisons). -- Brian Beck Adventurer of the First Order --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Googl

Re: Admin: How to ensure that at least on field is chosen from multiple fields.

2007-01-08 Thread Brian Beck
Ramdas S wrote: One question, validators are supposed to get deprecated once the new forms becomes the default. How do we use the newforms validation to do this? Hmm. I actually rather liked django.core.validators. My guess is that it's not currently possible to predict how this will be done

Re: Admin: How to ensure that at least on field is chosen from multiple fields.

2007-01-07 Thread Brian Beck
Couple more things I discovered... This page documents a RequiredIfOtherFieldsNotGiven validator that doesn't actually exist! http://www.djangoproject.com/documentation/forms/#validators (it's close to what you want but not exactly -- you want it to be required if *neither* of the other fields a

Re: Admin: How to ensure that at least on field is chosen from multiple fields.

2007-01-07 Thread Brian Beck
Whoops, don't forget to add this wherever you put that RequiredIfNoneGiven code: from django.core.validators import gettext_lazy, ValidationError --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" grou

Re: Admin: How to ensure that at least on field is chosen from multiple fields.

2007-01-07 Thread Brian Beck
borntonetwork wrote: I have a model object called Customer. It contains the typical attributes/fields you might expect (name, street, apt, city, state, etc). Among these fields are 3 called home_phone, work_phone, and cell_phone. In the admin web interface, I need to ensure that the user must e

Re: floatfield( blank=True ) wierdness

2007-01-07 Thread Brian Beck
borough peter wrote: Yet the admin interface doesn't allow me to leave it empty: IntegrityError at /xxx/xx/xxx/add/ xxx_x.myfloat may not be NULL Hi, blank=True allows admin interface input to be an empty string, while null=True allows it to be NULL in the database. You want both. C

Re: Good Web development practice

2007-01-07 Thread Brian Beck
[EMAIL PROTECTED] wrote: Any usage of Redirect breaks Back button (or at least makes it usage more difficult since you need to go back a one step more). It doesn't introduce an extra Back step; this isn't like a META EQUIV redirect or whatever. Pressing back still works to get them to the pag

Re: AttributeError: 'WSGIRequest' object has no attribute 'user'

2007-01-04 Thread Brian Beck
It would seem that something is happening between the authentication middleware setting request.__class__.user and the context processor reading it. Couple things to try if you're in a debugging mood: After line 11 in django/contrib/admin/middleware.py: request.__class__.user = LazyUser() +

Re: In Model or Manager? (Sorting, calculations, and non-savable fields)

2007-01-04 Thread Brian Beck
Brian Beck wrote: class Payment(models.Model): ... class Custom: def sortable_fields = ['amount', 'received_date'] That last line should of course just be: sortable_fields = ['amount', 'received_date'] --~--~-~--~~--

Re: In Model or Manager? (Sorting, calculations, and non-savable fields)

2007-01-04 Thread Brian Beck
ringemup wrote: Does that apply to the actual sorting of the data as well? It seems to me that it's something most efficiently accomplished at the database level. If sorting will always be done by field in the model (and not some complex combination, for example), and SQL orders it how you're

Re: Looking to move to Django, is it right for me?

2007-01-04 Thread Brian Beck
A lot of time has been spent on making Django not-too-magical while keeping the rapid development time. I've found that it rarely does too much automatic stuff behind my back. Just a couple examples of high-level stuff that isn't too-high-for-your-own-good: * Database access. You can still use

Unpacking in template loops

2007-01-03 Thread Brian Beck
Sorry if this has been brought up before, I tried searching... Would it be too complex/controller-y/confusing to allow sequence unpacking in Django's for loops? As far as I can tell it isn't supported. So for example, if I have a list... fruits = [('apple', 10), ('orange', 5), ('banana', 7)]

Re: Is there an easy to "humanize" a list?

2006-12-20 Thread Brian Beck
from django.utils.text import get_text_list --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, s

Re: Simple CAS 1.0 authentication

2006-12-04 Thread Brian Beck
tonemcd wrote: > Again, thanks heaps for making this available - it's done the business > for me! Tone, Awesome! Glad it worked. :) Brian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To

Re: Overwriting the save-function in automatic admin?

2006-12-02 Thread Brian Beck
Hi Tim, James Bennett wrote about how to do this not too long ago, check it out here: http://www.b-list.org/weblog/2006/11/02/django-tips-auto-populated-fields -- Brian Beck Adventurer of the First Order --~--~-~--~~~---~--~~ You received this message because

Re: Auto-login with REMOTE_USER

2006-12-01 Thread Brian Beck
Ivan Sagalaev wrote: > Brian Beck wrote: > > I don't understand how this is related to the admin interface. > > Admin interface won't display a login page if you already have > request.user set to an existing user. (if I'm not mistaken :-) ). Yep, okay. I wa

Re: Auto-login with REMOTE_USER

2006-12-01 Thread Brian Beck
Brian Beck wrote: > I don't understand how this is related to the admin interface. Anyway, > shouldn't it go after the standard auth middleware, so that > django.contrib.auth.middleware doesn't clobber the request.user that > the middleware posted above sets? And

Re: Auto-login with REMOTE_USER

2006-12-01 Thread Brian Beck
I don't understand how this is related to the admin interface. Anyway, shouldn't it go after the standard auth middleware, so that django.contrib.auth.middleware doesn't clobber the request.user that the middleware posted above sets? And you still need to take into account the admin interface's

Re: Auto-login with REMOTE_USER

2006-12-01 Thread Brian Beck
I just wanted to add that if you want to use this method in combination with the bundled admin interface, you're gonna have to intercept any admin requests and do the authentication so that it won't show the login form. Check the latest post in the CAS authentication thread, the middleware code t

Re: Simple CAS 1.0 authentication

2006-12-01 Thread Brian Beck
Alright, I fixed things up a bit and went for the middleware approach. The CAS module can now intercept all admin interface requests and do the appropriate authentication routine instead of showing the login form. Everything can now be configured in settings.py as well so there's no need to muck

Registering defaults for custom settings

2006-11-30 Thread Brian Beck
Hi, If I'm developing middleware or an app that I want a user to be able to configure in their settings.py, how should I go about setting defaults in there? I checked out django.conf, and it just looks like global_settings.py registers the defaults for every possible module included with Django.

Re: Simple CAS 1.0 authentication

2006-11-30 Thread Brian Beck
Alright, I'm gonna throw a question out there, maybe someone can help. As shown above I can intercept the admin index page in order to not display the login form which doesn't make sense for CAS authentication. However, this only works if the user needs to be authenticated and requests the index

Re: Simple CAS 1.0 authentication

2006-11-30 Thread Brian Beck
Quick followup in case anyone is interested (anyone? Bueller?)... One problem is handling the admin site, which doesn't really account for an authentication backend that doesn't know the user's password (making the login form useless). So, without wanting to hack up django.contrib.admin, here's

Re: More questions on models

2006-11-27 Thread Brian Beck
rItem(quantity=10, price=1.5, total=2, order=o, product=p).save() >>> OrderItem(quantity=5, price=10.5, total=20, order=o, product=p).save() Here's the part you want: >>> o.orderitem_set.all() [, ] Hope that helps. -- Brian Beck Adventurer of the First Order --~--~

Simple CAS 1.0 authentication

2006-11-27 Thread Brian Beck
#x27;t forget to put 'your_site.cas' in INSTALLED_APPS and enable 'django.contrib.auth'. Also see cas/backends.py if you have a way to automatically determine the user's name and e-mail from the username (from LDAP for example), or if you need to implement more of the CAS protocol