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
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
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
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
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
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
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
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&
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
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?
>
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
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.
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)
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
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,
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
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
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.
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
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 =
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
--~--~-~--~~~---~-
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
>
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
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
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
> 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
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
27 matches
Mail list logo