Using a Django project in a python script.

2006-07-05 Thread xin
As a part of the application I'm writing I need to do certain things to the database every night. The easiest way to implement this would be a python script run every night by cron. As django offers an interactive shell (through manage.py) I figured there must be a way to use this functionality

*_set (ForeignKey accessors) broken?

2006-07-05 Thread m h
I'll just post the contents of my bug report. Has anyone else ran into this? Any hints, suggestions? http://code.djangoproject.com/ticket/2297 I revved to v3278 and my app broke. In my view I adjust some fields of the model. My model looks something like this (quite simplified) class

Re: Code exectution and persistent object question

2006-07-05 Thread Iain Duncan
>>Ok, so we're would be smart place to do housekeeping you want to have >>happen no matter what page is loaded? > > > Middleware: http://www.djangoproject.com/documentation/middleware/ > > You can have functions that run prior to a request being passed along, > prior to a view function being

Re: union and intersection of querysets

2006-07-05 Thread Malcolm Tredinnick
On Thu, 2006-07-06 at 02:55 +, Lorin Hochstein wrote: > Malcolm Tredinnick wrote: > > On Wed, 2006-07-05 at 21:38 +, Lorin Hochstein wrote: > > > > One of these (all hypotheses related to any topic on the list) is easy: > > > > Hypothesis.objects.filter(topics__in = topics) > > >

Re: union and intersection of querysets

2006-07-05 Thread Lorin Hochstein
Malcolm Tredinnick wrote: > On Wed, 2006-07-05 at 21:38 +, Lorin Hochstein wrote: > > One of these (all hypotheses related to any topic on the list) is easy: > > Hypothesis.objects.filter(topics__in = topics) > Ah, nice and simple... Somehow I manage to miss that in the docs.

Re: Code exectution and persistent object question

2006-07-05 Thread Malcolm Tredinnick
On Thu, 2006-07-06 at 02:02 -0700, Iain Duncan wrote: > > Separate client hits might hit separate Python interpreter instances, > > and each of those instances will have imported the global namespace on > > their own, creating separate global namespaces. > > > > So like Steven said, it's not

Re: Code exectution and persistent object question

2006-07-05 Thread Iain Duncan
> Separate client hits might hit separate Python interpreter instances, > and each of those instances will have imported the global namespace on > their own, creating separate global namespaces. > > So like Steven said, it's not safe to do anything in the global > namespace. If you need a

Re: union and intersection of querysets

2006-07-05 Thread Russell Keith-Magee
On 7/6/06, Lorin Hochstein <[EMAIL PROTECTED]> wrote: I realize I can do this using Python sets on the id's, but is there away to do it more efficiently using the database API?At present - not really. Malcolm has pretty much covered the currently available options. However, I would point out that

Re: Viewing generated SQL

2006-07-05 Thread Adrian Holovaty
On 7/5/06, AlanG <[EMAIL PROTECTED]> wrote: > Is there a simple way see the query SQL generated by Django? Sure is! See the FAQ: http://www.djangoproject.com/documentation/faq/#how-can-i-see-the-raw-sql-queries-django-is-running Adrian -- Adrian Holovaty holovaty.com | djangoproject.com

Re: Django & Apache 1.x

2006-07-05 Thread gabor
PythonistL wrote: > Gabor, > what trafic do you have at your website and what server configuration > do you use? I am asking that because you use FastCGI and I had big > problems with FastCGI when there was highload.So I decided to move to > mod_python and no problem since > Regards, > L hi,

Viewing generated SQL

2006-07-05 Thread AlanG
Is there a simple way see the query SQL generated by Django? Specifically if I execute a query like so: entries = Entry.objects.filter( headline__startswith='What').exclude( pub_date__gte=datetime.now()).filter( pub_date__gte=datetime(2005, 1, 1)) can I

Re: Code exectution and persistent object question

2006-07-05 Thread Jay Parlar
On 7/6/06, Iain Duncan <[EMAIL PROTECTED]> wrote: > > > > Code in the global namespace is executed at module import time. > > These variables live as long as the python interpreter runs. (at least > > thats my understanding of it) > > > > This is great for constants and such, but you can't rely

Re: Managing database privileges

2006-07-05 Thread Ian Holsman
On 06/07/2006, at 4:56 AM, [EMAIL PROTECTED] wrote: > > So does your database only have one user created and you specify > that in > the settings file or whenever you want to inspect the database by > hand? > > I'm under the impression that having a separate database user for the > web

Re: Code exectution and persistent object question

2006-07-05 Thread Iain Duncan
> Code in the global namespace is executed at module import time. > These variables live as long as the python interpreter runs. (at least > thats my understanding of it) > > This is great for constants and such, but you can't rely on it to store > state variables as, depending on the

Re: Deletion of foreign key relations in admin view?

2006-07-05 Thread Iain Duncan
>>This feels more like a problem to be solved at the database level; the >>ideal solution would be to set 'ON DELETE SET NULL' for the >>foreign-key column (assuming -- and I don't know if this is the case >>-- that Django is doing 'ON DELETE CASCADE'). Just make sure that >>column will accept

union and intersection of querysets

2006-07-05 Thread Lorin Hochstein
Hi, I had a question about the database API. I have two models, Hypothesis and Topic, with a many-to-many relationship. Given a list of topics, what I want to do is retrieve the union of related hypotheses (all hypotheses that are associated with any topic in the list) and the intersection of

Re: Managing database privileges

2006-07-05 Thread nate-django
On Tue, Jul 04, 2006 at 11:23:16PM -0300, Douglas Campos wrote: > you can specify what user/password to connect to database in > settings.py file, under your project dir > > http://www.djangoproject.com/documentation/tutorial1/#database-setup True, but that's not what I was asking. > On

Re: Store and retrieve template code from database

2006-07-05 Thread plungerman
hello malcom, thanks for taking the time to help out. Malcolm Tredinnick wrote: > On Wed, 2006-07-05 at 12:32 +, plungerman wrote: > > greetings, > > > > i would like to store django template code in a database and retrieve > > it for display. before i go any further, does anyone foresee

Re: Documentation for hosting providers?

2006-07-05 Thread Adrian Holovaty
On 7/5/06, Carlos Yoder <[EMAIL PROTECTED]> wrote: > Would it be possible to put together a Wiki entry on how to provide > support for Django, especially geared towards busy ISP admins? It > should certainly help me (selfish selfish selfish), but I'm sure also > other people too. Hey Carlos, I

Re: Store and retrieve template code from database

2006-07-05 Thread hugo
Hi, Adrian Holovaty wrote: > It's a bit old, and I'm not sure whether he's updated it for the > newest Django -- but it could be a good starting point. I didn't, yet. But someone on the IRC channel said he wanted to look into that, so maybe someone else should be up with something like this. It

Re: generating md5-hashes in modpython fails

2006-07-05 Thread Nikolaus Schlemm
for anybody who's also experiencing this problem, Alain Tesio mentioned another odd factor and its workaround on the modpy-mailinglist: http://modpython.org/pipermail/mod_python/2006-July/021544.html -- cheers, Nikl --~--~-~--~~~---~--~~ You

Re: Store and retrieve template code from database

2006-07-05 Thread Adrian Holovaty
On 7/5/06, plungerman <[EMAIL PROTECTED]> wrote: > i would like to store django template code in a database and retrieve > it for display. See Hugo's implementation here: http://code.djangoproject.com/ticket/632 It's a bit old, and I'm not sure whether he's updated it for the newest Django --

Re: Django & Apache 1.x

2006-07-05 Thread PythonistL
Gabor, what trafic do you have at your website and what server configuration do you use? I am asking that because you use FastCGI and I had big problems with FastCGI when there was highload.So I decided to move to mod_python and no problem since Regards, L

Re: Store and retrieve template code from database

2006-07-05 Thread Simon Willison
On 5 Jul 2006, at 14:32, plungerman wrote: > i would like to store django template code in a database and retrieve > it for display. The Django template system was originally designed with this exact use-case in mind - we made sure that there was flexibility as to where the templates were

Re: Store and retrieve template code from database

2006-07-05 Thread Malcolm Tredinnick
On Wed, 2006-07-05 at 12:32 +, plungerman wrote: > greetings, > > i would like to store django template code in a database and retrieve > it for display. before i go any further, does anyone foresee any > security risks with this approach? there will be control over those > users who can

Re: Adding a value to the request.session in a middleware

2006-07-05 Thread Malcolm Tredinnick
On Wed, 2006-07-05 at 14:20 +0200, Guillermo Fernandez Castellanos wrote: > Hi, > > I am programming a middleware that keeps track of the visits made to > my webpage. I keep track of the IP addresses and I add to this a Visit > each time a user comes back. I consider a visit is new when a given

Store and retrieve template code from database

2006-07-05 Thread plungerman
greetings, i would like to store django template code in a database and retrieve it for display. before i go any further, does anyone foresee any security risks with this approach? there will be control over those users who can manipulate the data but not so much that we could monitor what

Adding a value to the request.session in a middleware

2006-07-05 Thread Guillermo Fernandez Castellanos
Hi, I am programming a middleware that keeps track of the visits made to my webpage. I keep track of the IP addresses and I add to this a Visit each time a user comes back. I consider a visit is new when a given interval (30 minutes,...) passes between visits. In order to keep track of the last

Re: after_acreate after_change

2006-07-05 Thread DavidA
Malcolm Tredinnick wrote: > You've drifted a bit from the original topic here, though, haven't you? Um, yes. Guilty as charged... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to

Re: Packaging django/flup for ubuntu

2006-07-05 Thread Brett Parker
On Wed, Jul 05, 2006 at 09:28:39AM +0100, David Reynolds wrote: > > > On 4 Jul 2006, at 10:47 pm, Jan Claeys wrote: > > > > > On ma, 2006-06-26 at 22:26 -0300, Douglas Campos wrote: > >> does anyone have some light for me? I'm new to this ubuntu thing > >> > >> I want to mantain a nightly .deb

Re: Packaging django/flup for ubuntu

2006-07-05 Thread Douglas Campos
thanx On 7/5/06, David Reynolds <[EMAIL PROTECTED]> wrote: > > > On 4 Jul 2006, at 10:47 pm, Jan Claeys wrote: > > > > > On ma, 2006-06-26 at 22:26 -0300, Douglas Campos wrote: > >> does anyone have some light for me? I'm new to this ubuntu thing > >> > >> I want to mantain a nightly .deb build

Documentation for hosting providers?

2006-07-05 Thread Carlos Yoder
Hello people, Maybe you missed the thread about "Django and Apache 1.x" on this list -- I know I can't keep track of it! We're talking about the docs can be a little misleading as to all the possible server configurations needed to successfully run Django. Currently I'm hitting a wall with the

Re: Deletion of foreign key relations in admin view?

2006-07-05 Thread James Bennett
On 7/5/06, James Bennett <[EMAIL PROTECTED]> wrote: > This feels more like a problem to be solved at the database level; the > ideal solution would be to set 'ON DELETE SET NULL' for the > foreign-key column (assuming -- and I don't know if this is the case > -- that Django is doing 'ON DELETE

Re: Deletion of foreign key relations in admin view?

2006-07-05 Thread James Bennett
On 7/4/06, Iain Duncan <[EMAIL PROTECTED]> wrote: > Can anyone tell me where in the docs to look for how to overide the > deletion behaviour so that instead of dependecies and dependers getting > mutually deleted, the foreign key in question can just revert to a null > value? Concrete example is

Re: Packaging django/flup for ubuntu

2006-07-05 Thread David Reynolds
On 4 Jul 2006, at 10:47 pm, Jan Claeys wrote: > > On ma, 2006-06-26 at 22:26 -0300, Douglas Campos wrote: >> does anyone have some light for me? I'm new to this ubuntu thing >> >> I want to mantain a nightly .deb build from django svn, to help >> the poor (tm) > > There is a packaging guide

Re: Django & Apache 1.x

2006-07-05 Thread Carlos Yoder
> I am not a doc wizard, but IMHO it is *always* worth addressing doc > issues re set up that are ambiguous and make one wonder how to get > started. I think most open source projects vastly undersestimate how > important ease of entry is to their growth. This encompasses both how > easy it is to

Re: Deletion of foreign key relations in admin view?

2006-07-05 Thread [EMAIL PROTECTED]
I posted a similar complaint in the developers group, perhaps you find it interesting: http://groups.google.com/group/django-developers/browse_frm/thread/94004980dfedc3f1 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

Re: Problem with apps in admin

2006-07-05 Thread Malcolm Tredinnick
On Tue, 2006-07-04 at 07:20 -0700, Enrico wrote: > I'm following the tutorial: > http://www.djangoproject.com/documentation/tutorial2/ > > And I couldn't get the admin working by just uncommenting the > "Uncomment this for admin:" line. Do you mean this didn't work when you were using the

Re: dynamic limit_choices_to issues

2006-07-05 Thread william
Indeed, you are correct, but that does not solve the issue. still with the error: 'ForeignKey' object has no attribute 'application' Matt McDonald wrote: > Shouldn't that be: > limit_choices_to= > {'meeting__application__name__exact':meeting.application.name} > > On 05/07/2006, at 6:53 AM,