Re: Q lookup with both OR and AND

2007-09-05 Thread Kevin Menard

Without looking into your problem in any real detail (sorry, late
here), you could probably apply DeMorgan's Law and come up with a
single predicate that you use throughout your query, using negation as
appropriate.  That may help you out.

-- 
Kevin

On 9/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> I'm having trouble piecing together a query for this model:
>
> class Ticket(models.Model):
> ...
> assigned_user = models.ForeignKey(User)
> name = models.CharField(maxlength=255)
> private = models.BooleanField(default=False)
>
> I'm trying to get all the tickets where the tickets are not private OR
> the ticket is private and assigned to the current user.
>
> I'm foggy on where I use the comma, pipe, and ampersand characters to
> get the query structured properly. In pseudo-sql, I'd say "select *
> where private = False or (private=True and username='snewman')
>
> I thought I was close with this, but it only returned tickets assigned
> to me. (The parenthesis around the 2nd and 3rd Q's obviously didn't
> help)
>
> Ticket.objects.filter(Q(private__exact=False) |
> (Q(private__exact=True) & Q(assigned_user__username__exact='snewman')))
>
>
> >
>


-- 
Kevin

--~--~-~--~~~---~--~~
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, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django under 2.5

2007-08-29 Thread Kevin Menard

On 8/28/07, Alvaro MouriƱo <[EMAIL PROTECTED]> wrote:
>
> Hi list,
>
> I have been running django under python 2.4 but now I'm considering
> switching to 2.5. Are there any known compatibility issues? Or is it
> just straightforward?

I've been running under 2.5 without any problems.  The same codebase
works under 2.4 as well.

-- 
Kevin

--~--~-~--~~~---~--~~
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, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



[newforms-admin]: Preload hook?

2007-08-23 Thread Kevin Menard

Hi,

What's the best way to preload values into an admin form when using
newforms-admin?

I've managed to patch django to load form fields with default values
from my model fields.  But, this doesn't really allow for the
arbitrary code based on the request that I would like.  In particular,
I'd like to be able to store the currently logged in user's id into a
required field as the form loads.  I can't seem to find a hook to do
that.

I have been able to accomplish what I wanted by overriding save_add()
and loosening the required restriction.  Obviously, by doing such, I
also lose expresiveness and safety checking when using the model in
any other context.

Anyone have any ideas on how to go about hooking in at form render/load?

-- 
Thanks,
Kevin

--~--~-~--~~~---~--~~
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, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Unique check errors when using postgres and explicit ids

2007-07-31 Thread Kevin Menard

On 7/31/07, Kai Kuehne <[EMAIL PROTECTED]> wrote:
>
> Hi list,
> I have a question regarding data imports with django
> and postgres.
> I used the database for my current application and used
> the db-dump script from here:
> http://www.djangosnippets.org/snippets/14/
>
> When I load data into the database, I cannot insert new
> data afterwards. (Some weird unique check errors.)

I would have to agree with lenducha's synopsis.  If the sequence is
not updated, you will run into duplicate ID problems.  The easiest
thing to do right now is update all of your sequence curvals to be
something large, where large is defined as being greater than count(*)
for each table.

-- 
Kevin

--~--~-~--~~~---~--~~
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, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Optimistic Locking Patch?

2007-07-31 Thread Kevin Menard

On 7/31/07, Victor Ng <[EMAIL PROTECTED]> wrote:
>
> Has anyone looked into implementing optimistic locking for the Django ORM?
>
> I didn't see anything logged into code.djangoproject.com or in the
> django-users list.
>
> Has anyone taken a stab at implementing this yet?

I haven't looked into this deeply, but my guess is "no".  Django's ORM
is designed for the common use case.  This typically means that no one
is changing the DB behind you.

If there is any work going on in this area, I'd be interested in
hearing about it as well.

-- 
Kevin

--~--~-~--~~~---~--~~
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, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pydev

2007-07-31 Thread Kevin Menard

On 7/31/07, eXt <[EMAIL PROTECTED]> wrote:
>
> I currently use Eclipse Europa with PyDev and it works fine. Earlier I
> worked with Eclipse 3.2 and IIRC I had some problems with lock ups but
> then I changed Eclipse start parameters and it solved my problem. So
> my advice is to upgrade your Eclipse or to read somewhere about
> parameters in Eclipse's start script. I don't remember these settings
> now, sorry.

Interesting.  The PyDev author has noted these problems:

http://pydev.blogspot.com/2007/07/problems-in-pydev-136.html
http://pydev.blogspot.com/2007/07/pydev-137-and-138.html

Whatever changes you made to eclipse are likely in the eclipse.ini
file.  If you post that, we might be able to see what it is that you
changed.


-- 
Kevin

--~--~-~--~~~---~--~~
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, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: [OT] pydev

2007-07-31 Thread Kevin Menard

On 7/31/07, Derek Anderson <[EMAIL PROTECTED]> wrote:
>
> hey all,
>
> i'm having a heck of a time using pydev (the eclipse python plugin).  it
> keeps randomly locking up eclipse (unresponsive UI + 100% CPU), usually
> when i switch tabs.  anyone else experiencing this?

If you are using Eclipse Europa, you'll likely run into problems.  It
seems PyDev hasn't been fully flexed on this platform, nor with JDK 6.
 Fabio has been sensitive to these issues and has been addressing them
fairly quickly.  It seems each new release gets us a little bit
closer.

If you stick with Eclipse 3.2 and JDK 5, you'll likely be okay.

-- 
Kevin

--~--~-~--~~~---~--~~
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, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: duplicate SQL statements

2007-07-31 Thread Kevin Menard

On 7/31/07, Thomas Guettler <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> with SQLLogMiddleware (http://www.djangosnippets.org/snippets/344/) I see,
> that there are many statements executed twice in a single request.
>
> This links explains it:
> http://www.djangoproject.com/documentation/db-api/#caching-and-querysets
>
> How can I cache the result of MyModelClass.objects.get(id=...) at least
> for one request.

My guess is that using the session could achieve this for you.  A
"flash" persistence strategy would be better, but I'm unaware of one
provided out of the box.

-- 
Kevin

--~--~-~--~~~---~--~~
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, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to communicate with Authorize.net?

2007-07-24 Thread Kevin Menard

On 7/22/07, Greg <[EMAIL PROTECTED]> wrote:
>
> Is there any documentation on how to send form data to a Authorize.net
> from within a Django view?

I've done this from a Java webapp we have here.  It's mostly just XML
datagram forming and parsing, using standard HTTP libs for POSTing.  I
don't think you'll run into anything in django that will help you out
or hold you back.

I'd check out the Authorize.net XML guide.  It's a pretty
straightforward, albeit klunky, process.

-- 
Kevin

--~--~-~--~~~---~--~~
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, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django on win xp

2006-07-22 Thread Kevin Menard

On 7/22/06, Tyson Tate <[EMAIL PROTECTED]> wrote:
>
> Wait, Linux or XP?
>
> Regardless, you might want to read the documentation first:
>
> http://www.djangoproject.com/documentation/install/

Be sure to read the comments, too.  There is some useful info in there
on how to set up the symlinks in Windows.

-- 
Kevin

--~--~-~--~~~---~--~~
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, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Duct tape

2006-07-22 Thread Kevin Menard

On 7/21/06, Waylan Limberg <[EMAIL PROTECTED]> wrote:

> Which just so happens to be a separate application that is not in any
> way required to use django. Of course, if you elect to take that
> route, you'll have to build your own 'less magical' backend. But if
> that makes you feel more comfortable you are given that option.
> Nothing scarey there.

While I can see the point you're trying to make, it seems like you're
trying to dismiss his point as a technicality rather than address it
at a technical level.  The admin app is supported by the django devs,
ships with django, and is a large component of the tutorials.  For all
intents and purposes (especially to someone just starting off), it is
django.  The original poster's problem was with "magic" in django, not
just the core framework.

FWIW, I don't necessarily agree with him.  I just hate seeing concerns
being dismissed due to word choice.

-- 
Kevin

--~--~-~--~~~---~--~~
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, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---