Re: using re.sub with unicode string in response middleware

2008-01-08 Thread Gary Wilson Jr.
Malcolm Tredinnick wrote: > Hey Gary, > > On Tue, 2008-01-08 at 00:35 -0600, Gary Wilson Jr. wrote: > [...] >> So, looking at a couple places in Django trunk where response.content is >> used, >> these look like bugs: >> >> >> django.contrib

Re: using re.sub with unicode string in response middleware

2008-01-07 Thread Gary Wilson Jr.
Malcolm Tredinnick wrote: > On Mon, 2008-01-07 at 18:28 -0600, Gary Wilson Jr. wrote: >> Malcolm Tredinnick wrote: >>> On Sun, 2008-01-06 at 15:25 -0600, Gary Wilson Jr. wrote: >>>> It appears that at this point, response.content is a utf8-encoded >

Re: using re.sub with unicode string in response middleware

2008-01-07 Thread Gary Wilson Jr.
Malcolm Tredinnick wrote: > On Sun, 2008-01-06 at 15:25 -0600, Gary Wilson Jr. wrote: >> It appears that at this point, response.content is a utf8-encoded bytestring. >> I'm playing with a response middleware doing something like: >> >> MY_RE.sub(u'%s' % text, response.

using re.sub with unicode string in response middleware

2008-01-06 Thread Gary Wilson Jr.
It appears that at this point, response.content is a utf8-encoded bytestring. I'm playing with a response middleware doing something like: MY_RE.sub(u'%s' % text, response.content) which raises a UnicodeDecodeError if response.content contains non-ascii. I understand that the strings need to

Re: @url tag - getting rid of urlpatterns

2007-08-30 Thread Gary Wilson
On Aug 30, 3:08 am, Ilya Semenov <[EMAIL PROTECTED]> wrote: > Second, I think the use of generic views is over-estimated. I tend to agree a bit here. I like having all my URLs in one file and all my views in another. Using generic views usually clutters the urls file too much for me. Generic

Re: There's got to be a better way

2007-07-27 Thread Gary Wilson
On Jul 26, 1:22 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > In my view, I have: > future_events = Event.objects.filter(start_date__gte=now) > pacific_events = future_events.filter(club__region='Pacific') > rocky_mountain_events = future_events.filter(club__region='Rocky >

Re: a very slow view, > 30secs to load

2007-03-29 Thread Gary Wilson
On Mar 29, 2:26 pm, "Milan Andric" <[EMAIL PROTECTED]> wrote: > But in the dev environment I can see pretty well that the view is > functioning very quickly. So your hunch about the problem lying in > the templates is probably right. If you aren't seeing the slowdown on your dev server, then

newforms and form_from_instance

2007-03-28 Thread Gary Wilson
Starting to play around with newforms and I am trying to create a form with fewer fields than the model and post-fill those fields in the view. With the following example models and form: class Book(models.Model): author = models.CharField(maxlength=100, blank=True) title =

Re: django admin - too many sql-queries

2007-02-18 Thread Gary Wilson
On Feb 18, 10:48 am, "Honza Král" <[EMAIL PROTECTED]> wrote: > On 2/18/07, Tom? Pokorn? <[EMAIL PROTECTED]> wrote: > > > models.py attached. > > > On Sun, 2007-02-18 at 16:51 +0100, Honza Kr?l wrote: > > > > that's odd can you post your Model definition? > > definitely odd, list_select_related

duplicate error messages above FileField in admin interface

2006-11-14 Thread Gary Wilson
I've got a FieldField using the RequiredIfOtherFieldNotGiven validator, and when I try to save the object without filling in the "other field," I get two duplicate error messages above the file upload box. I assume this has something to do with FileField really using two form field widgets, but

Re: Setting up an new app with a models directory

2006-09-27 Thread Gary Wilson
Malcolm Tredinnick wrote: > When you have models in a deeper structure like this, you need to > explicitly tell the model what the app name is. You do this as follows: > > class SimpleTest(models.Model): > ... > class Meta: > app_label="appfolder" > >

Re: Strange Error when 404 or 500 error

2006-09-18 Thread Gary Wilson
[EMAIL PROTECTED] wrote: > File "/usr/lib/python2.4/site-packages/django/views/debug.py", line > 144, in technical_404_response > t = Template(TECHNICAL_404_TEMPLATE, name='Technical 404 template') > > TypeError: __init__() got an unexpected keyword argument 'name' >

Re: viewing generated SQL without running the query

2006-08-29 Thread Gary Wilson
Malcolm Tredinnick wrote: > On Tue, 2006-08-29 at 03:53 +0000, Gary Wilson wrote: > > I see that there is a _get_sql_clause() method, but is there a function > > that will return the constructed query string? > > Deja vu. I tried to implement something like this a little wh

Re: python sets and objects returned in queries

2006-08-29 Thread Gary Wilson
Ivan Sagalaev wrote: > Gary Wilson wrote: > > Why can't objects be used in python sets? Example: > > > >>>> [u.username for u in User.objects.all()] > > ['bar', 'foo', 'foobar'] > >>>> a = User.objects.filter(username__contains='foo') >

python sets and objects returned in queries

2006-08-28 Thread Gary Wilson
Why can't objects be used in python sets? Example: >>> [u.username for u in User.objects.all()] ['bar', 'foo', 'foobar'] >>> a = User.objects.filter(username__contains='foo') >>> b = User.objects.filter(username__contains='bar') >>> set.intersection(set(a), set(b)) set([]) but... >>> a [, ]

Re: Finding entries with multiple tags

2006-08-28 Thread Gary Wilson
[EMAIL PROTECTED] wrote: > > def tags(request, url): > > # Don't need the last item in the list since it will > > # always be an empty string since Django will append > > # a slash character to the end of URLs by default. > > tags = url.split('/')[:-1] > > posts =

viewing generated SQL without running the query

2006-08-28 Thread Gary Wilson
I see that there is a _get_sql_clause() method, but is there a function that will return the constructed query string? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,

Re: Filter "date" and FormFieldWrapper attribute error

2006-08-27 Thread Gary Wilson
Andres Luga wrote: > when displaying a form for a new object, I'm trying to set a default > value for a date field using a filter in a template, like so: > > > {{ form.somefield|date:"Y-m-d" }} > > This gives me an error: > 'FormFieldWrapper' object has no attribute 'year'. > What am I doing

Re: Finding entries with multiple tags

2006-08-27 Thread Gary Wilson
[EMAIL PROTECTED] wrote: > Hello - > > I'm playing around with a blog application and I want it to have a > tagging feature. I have the usual ManyToMany relationship set up with > Post and Tag (I'm not going to past my model since I think everyone is > familiar with this kind of setup). > > I

Re: SQL initial data for auth

2006-08-27 Thread Gary Wilson
> Hence, I've put a list of users into my 'auth/sql/User.sql' file, but > ./manage.py syncdb doesn't seem to pick up the existence of the file. > I have no doubt it's in the wrong place, but my question is which is > the correct place? :-) I think the file needs to be placed at

Re: Limit view to group members: what function for the @user_passes_test decorator?

2006-08-27 Thread Gary Wilson
cyberco wrote: > I want to limit a view to certain group members, so I'm using the > following decorator: > > @user_passes_test(lambda u: Group.objects.get(name='admin') in > u.groups.all(), login_url='/accounts/login/') > > This seems a little verbose. Is there a better way? user_passes_test is

Re: database newby question

2006-08-26 Thread Gary Wilson
[EMAIL PROTECTED] wrote: > i imported 2 users in the model LoginInfo the first is lab_id = '100' > and the second is lab_id = '200' > how do i put in the data in the class Modules ? > > what i thought i had to do was first create a object from the LoginInfo > class like > p =

Re: Searching on a calculated value

2006-05-25 Thread Gary Wilson
Adrian Holovaty wrote: > You're best off searching by the exact fields rather than messing with > derived fields. Would you offer some insight please? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users"

Re: Searching on a calculated value

2006-05-24 Thread Gary Wilson
Adrian Holovaty wrote: > On 5/23/06, Gary Wilson <[EMAIL PROTECTED]> wrote: > > Yes, I guess I could split the text entered and then do a search for > > each word in both first_name and last_name like the admin interface > > does... just seems like this would return ma

Re: Searching on a calculated value

2006-05-23 Thread Gary Wilson
Waylan Limberg wrote: > For an example of how the admin app does this see search_fields > http://www.djangoproject.com/documentation/model_api/#search-fields > > -- > > Waylan Limberg > [EMAIL PROTECTED] Yes, I guess I could split the text entered and then do a search for each word in both

Searching on a calculated value

2006-05-23 Thread Gary Wilson
calculated full name in the database)? Something like... User.objects.filter(get_full_name__iequals="Gary Wilson") --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To