Re: forms and modelform

2008-12-03 Thread grahamu
Buddy, I found this, you might give it a try. http://www.djangosnippets.org/snippets/703/ Graham On Nov 28, 9:59 am, Buddy <[EMAIL PROTECTED]> wrote: > Yes, I try it before to my ask here. I get error if use likethis > (class B(forms.ModelForm, A): > > ### > TypeError at /A/ > > Error when cal

DB record retrieval from every N minutes

2008-10-14 Thread grahamu
I'd like to find an efficient method to retrieve a list of Django DB records (model has a DateTimeField `timestamp`) between datetime 'start' and datetime 'end' with a few conditions. First, we're looking for a record once every 'interval' minutes. Second, I only want a record if it's timestamp wi

Re: DB record retrieval from every N minutes

2008-10-16 Thread grahamu
Good idea Thomas. I'll experiment with using __range to get 24 individual records instead of retrieving all records and then looping over the queryset. Thanks. Graham On Oct 15, 1:15 am, Thomas Guettler <[EMAIL PROTECTED]> wrote: > grahamu schrieb:> I'd like to find

Adding ManyToMany field to django comments

2009-08-19 Thread grahamu
In general, I'm wondering how to retrieve a Queryset provided to a Form (choices for a ManyToMany field) from within a view that only accepts POST data from that form. This isn't really a question about extending django.contrib.comments, but that framework provides a good point of reference for th

Re: Displaying username on every page

2009-08-19 Thread grahamu
If you use RequestContext(), you automatically get visibility to the current user and their permissions. See http://docs.djangoproject.com/en/dev/topics/auth/#authentication-data-in-templates. My base templates use a block like this: {% block user %} {% if user.is_authenti

Re: Adding ManyToMany field to django comments

2009-08-25 Thread grahamu
this solution is problematic in nature. Thanks! Graham On Aug 19, 5:56 pm, grahamu wrote: > In general, I'm wondering how to retrieve a Queryset provided to a > Form (choices for a ManyToMany field) from within a view that only > accepts POST data from that form. This isn't

Why does admin fail on one project and not another?

2010-01-27 Thread grahamu
I'm having a problem with django admin working for one local project and not another. Both use the same version of Django (SVN-12311). Both have very similar settings.py files. The issue appears when I click on an app model class name in the root admin list (at "/admin/"). In this case I was tryin

Re: Why does admin fail on one project and not another?

2010-01-27 Thread grahamu
Two additional notes for this issue: 1. Clicking on _any_ model in the admin causes the same TypeError. 2. Clicking on "+Add" in admin for the User model yields a blank form! Clicking on "+Add" for any other model shows a valid form. On Jan 27, 3:08 pm, grahamu wrote: > I&

Newforms: Override FileField save method

2007-06-06 Thread grahamu
Does anyone here know where/how I should override the default save method for a newforms-based FileField? Specifically, I want to dictate the location where the file is saved because the location will be different for every instance of my model. Additionally I want to remove any existing file wit

Re: Newforms: Override FileField save method

2007-06-06 Thread grahamu
Just a clarification, the model instance save is being done via form.save(), not directly from the instance. Graham On Jun 6, 3:43 pm, grahamu <[EMAIL PROTECTED]> wrote: > Does anyone here know where/how I should override the default save > method for a newforms-based FileField? >

Re: Newforms: Override FileField save method

2007-06-06 Thread grahamu
ffect on where the uploaded files are stored, so I added this "save_FOO_file" method to the ToolRun model class: def save_input_file_file(filename, raw_contents): # save it in the correct subdir According to the debugger, this function is never called. Thanks for your

Re: YUI file upload and form errors

2008-01-28 Thread grahamu
when there is a file field, and yet the "normal" location contains an > escaped version of the response. > > FWIW, the normal location for the view response data is o.responseText. With > a file upload, the location is o.responseXML.body.textContent. > > Thanks again.

get blogs with no entries

2008-02-07 Thread grahamu
Using the conventional Blog and Entry models from the Django database API docs: class Blog(models.Model): name = models.CharField(max_length=100) ... class Entry(models.Model): blog = models.ForeignKey(Blog) headline = models.CharField(max_length=255)

Re: get blogs with no entries

2008-02-07 Thread grahamu
The best I've been able to come up with is: qs1 = Blog.objects.all() qs2 = qs1.filter(entry__blog__isnull=False) qs3 = filter(lambda x: x not in qs2, qs1) Surely there is a better method. On Feb 7, 1:02 pm, grahamu <[EMAIL PROTECTED]> wrote: > Using the conventional Blog and Ent

reverse( ) and template tag 'url' fail when pattern has include

2008-02-13 Thread grahamu
Lots of people correctly suggest using named url patterns and the {% url %} template tag to obtain a URL. The concept is great and follows the DRY principle. However, I believe that if a pattern has an "include()" instead of a view function, the existing mechanism fails. An example of the problem,

Re: reverse( ) and template tag 'url' fail when pattern has include

2008-02-13 Thread grahamu
er apparently ignores the kwargs when presented with a function instead of a named URL. On Feb 13, 4:34 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote: > Hi, graham > > Imagine that your urls2.py has some number of patterns. And then you > call `reverse('eat')` what of the

Re: reverse( ) and template tag 'url' fail when pattern has include

2008-02-13 Thread grahamu
On Feb 13, 7:15 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: [...] > As Alex pointed out, you're calling reverse() on something that isn't a > direct URL pattern. Don't do that. It makes no sense to call reverse() > on something that is actually a collection of URL patterns. Instead, > pick

Re: reverse( ) and template tag 'url' fail when pattern has include

2008-02-13 Thread grahamu
On Feb 14, 12:04 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > That's because you are expecting things from reverse() that it > explicitly doesn't do. In particular, the "args" and "kwargs" parameters > to reverse are only checked against capturing groups in the URL's > regular expression.

setting newforms ModelChoiceField "selection"

2007-02-27 Thread grahamu
I'm struggling with a newforms issue. Specifically I'm trying to pre- select an option in a ModelChoiceField and I cannot figure out how this can be accomplished. Here are the code snippets: class Account(models.Model): title = models.CharField(maxlength=30, unique=True, db_index=True

Re: setting newforms ModelChoiceField "selection"

2007-02-27 Thread grahamu
Doh! If I had taken the time to read a post from two hours earlier I would have seen the answer. Use "initial" when instantiating the form. The last line below does the trick. if request.method == 'POST': form = FormClass(request.POST) if form.is_valid(): project =

how to get object after form.save() ?

2007-02-28 Thread grahamu
Hi all, Two newforms questions... 1. Is there an easy way to get the new object created by form.save()? 2. Is is true that one should not call form.save() if the form was instantiated from a class resulting from form_for_instance()? Thanks, Graham --~--~-~--~~~---~-

Re: how to get object after form.save() ?

2007-03-01 Thread grahamu
On Mar 1, 12:53 pm, "Honza Král" <[EMAIL PROTECTED]> wrote: > > 1. Is there an easy way to get the new object created by form.save()? > > obj = form.save() Thanks, I finally saw that after perusing the django source code. > > 2. Is is true that one should not call form.save() if the form was >

Re: Django IDE

2007-04-04 Thread grahamu
Sure, works great. My favorite (and perhaps most useful) feature is debugging a Django app and stepping through both my code and the Django code to find out what is happening. Graham On Apr 4, 6:56 pm, "Richard Blumberg" <[EMAIL PROTECTED]> wrote: > Has anyone had any experience using Komodo as a

YUI file upload and form errors

2008-01-02 Thread grahamu
Hi, I'm having a problem with Django "HTML escaping" JSON data sent in response to an asynchronous form submission when the form has an field. Forms that don't have a file field yield proper responses, and when Javascript is disabled on the browser normal form submissions work as well. I'm using

Re: YUI file upload and form errors

2008-01-02 Thread grahamu
On Jan 2, 4:43 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Wed, 2008-01-02 at 15:38 -0800, grahamu wrote: > > Hi, > > I'm having a problem with Django "HTML escaping" JSON data sent in > > response to an asynchronous form submission when th

Re: YUI file upload and form errors

2008-01-02 Thread grahamu
> On Jan 2, 4:43 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> > wrote: > > > > > On Wed, 2008-01-02 at 15:38 -0800, grahamu wrote: > > > Hi, > > > I'm having a problem with Django "HTML escaping" JSON data sent in > > > response

Re: YUI file upload and form errors

2008-01-02 Thread grahamu
On Jan 2, 7:13 pm, grahamu <[EMAIL PROTECTED]> wrote: > > On Jan 2, 4:43 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> > > wrote: > > > > On Wed, 2008-01-02 at 15:38 -0800, grahamu wrote: > > > > Hi, > > > > I'm having a problem wit