Re: Filtering a blank date field

2007-03-02 Thread Phil Powell
).get_query_set() objects = objects.filter(Q(active_from__isnull = True) | Q(active_from__lte = datetime.datetime.today())) objects = objects.filter(Q(active_to__isnull = True) | Q(active_to__gte = datetime.datetime.today())) return objects On 02/03/07, Phil Powell <[EMAIL PROTECTED]>

Filtering a blank date field

2007-03-02 Thread Phil Powell
I'm writing a custom Manager to only return objects which fall within dates set for Active From and Active To fields. It currently looks like this: class ActiveManager(models.Manager): def get_query_set(self): objects = super(ActiveManager, self).get_query_set() objects =

Re: newforms SelectDateWidget

2007-02-27 Thread Phil Powell
Thanks Mike - that did the trick. I thought there would be a simple solution - should have RTFM more thoroughly... On 27/02/07, Mike <[EMAIL PROTECTED]> wrote: > > The range function has an optional 'step' argument. > > Howzabout: > > SelectDateWidget(years=range(2006,1900,-1)) > > > But is

Re: Upcoming Django release, and the future

2007-02-27 Thread Phil Powell
On 26/02/07, James Bennett <[EMAIL PROTECTED]> wrote: > If there's a bug that's been annoying the heck out of you and you want > it fixed before the release, this would be the time to speak up about > it. We have a fairly high concentration of Django developers all in > one place with nothing to

newforms SelectDateWidget

2007-02-27 Thread Phil Powell
Just a quick query about the SelectDateWidget: The widget accepts an optional 'years' parameter for displaying a range of years, like this: SelectDateWidget(years = range(1900, 2006)) But is there an easy way I can make the years display in reverse - i.e. descending rather than ascending?

Using choices with newforms.form_for_model

2007-02-20 Thread Phil Powell
Hi, I have this: class SomeModel(models.Model): some_choice = models.CharField(maxlength=255, choices=CHOICES_DICT) And I'm generating a form for HTML display using this: SomeForm = newforms.models.form_for_model(SomeModel) form = SomeForm() But my some_choices field just shows up

Re: Newforms MultiValueField

2007-02-07 Thread Phil Powell
D]> wrote: > > Phil, > > > > I think you must subclass it and define the compress method. See the > > comments herehttp://code.djangoproject.com/browser/django/trunk/ > > django/newforms/fields.py#L412. You will also need a MultiWidget to > > go with the fie

Newforms MultiValueField

2007-02-06 Thread Phil Powell
Hi, Can anyone provide any pointers on how I use MultiValueField? Can I use it straight out of the box, or do I have to subclass to create a new field and a new MultiValueWidget? I thought that this code would just work: postcode = forms.MultiValueField(fields=(forms.CharField(max_length=4),

Re: Cent OS Deployment

2007-01-29 Thread Phil Powell
I've currently got a large-scale app in development on CentOS (but to be deployed on Red Hat), but it's running on Python 2.3. Aside from your Python install, there are also a few pre-requisites you might need to install alongside Django, such as MySQL-Python. Don't know if it's any help, but

"cannot import" error when doing an import of an app's models

2007-01-26 Thread Phil Powell
This is a very odd one: I have a number of apps installed, and I'm updating models.py in one of them to import the models of another, like this: from mysite.myapp1.models import MyModel Nothing unusual about that, huh? Except now if I run manage.py validate, I get errors like this:

Generic form appearing on multiple pages

2007-01-17 Thread Phil Powell
Hi - got a bit of a tricky one, which I can't quite come up with a sensible design pattern for: I have a contact form, which appears on a number of different pages across a site. To keep it generic and cut down on duplication of code, my thinking was that I should create a templatetag to

Re: Re: Singleton model instance

2006-12-07 Thread Phil Powell
can come up with more specific and/or efficient variants > on this theme, but basically this is going down the road that leads to > content management systems, which have solved this basic problem for > some time now :) > > Regards, > Jeff > > Phil Powell wrote: > &

Re: Re: Singleton model instance

2006-12-04 Thread Phil Powell
On 04/12/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > I'm not sure I get how a singleton would solve the "pages generated from > multiple chunks" problem. > > why not just use a model that holds (pagename, chunkname, chunk data) > triplets, and use a view that brings up all the chunks for a

Singleton model instance

2006-12-04 Thread Phil Powell
Hi all, Apologies if this has been asked on the list before, but a search didn't throw up anything relevant. I want to have a series of pages, with certain areas of content which are editable. I don't want to use flatpages, as I'd like the editable content to be broken down into chunks, rather

Re: Using a session variable in templates

2006-08-02 Thread Phil Powell
That sounds like just the thing I need - to hook into every request and inject into the context dictionary. Will give it a try. Thanks Chris! On 01/08/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Context processors might work: >

Using a session variable in templates

2006-08-01 Thread Phil Powell
Hi all, I'm trying to implement something I'd imagine is quite simple, but have come a bit unstuck when it comes to finding a graceful way to so it. What I want to do is sotre a random number (easy enough) in the users session, then retrieve it in my base template (this is for the purpose of

Batch record processing

2006-07-26 Thread Phil Powell
Hi all, I've got a Django app with a whole stack of data which I want to be able to update on a semi-regular basis. It's currently in Excel format, which is then easily converted to CSV and imported into a pre-defined MySQL table, with a relevant Django model defined around it. It all works

Re: Caching in Django admin

2006-07-20 Thread Phil Powell
That's excellent - strange I came across the problem right at the same time you were fixing it ;) -P On 20/07/06, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote: > > On Jul 20, 2006, at 4:45 AM, Phil Powell wrote: > > It seems odd that this doesn't seem to have popped up as

Re: Caching in Django admin

2006-07-20 Thread Phil Powell
Thanks for the feedback guys - good to know that I'm not alone in seeing this behaviour. It seems odd that this doesn't seem to have popped up as a common issue, if it is indeed something related to site-wide caching - it's definitely a bit of a show-stopper when it comes to having a client

Caching in Django admin

2006-07-19 Thread Phil Powell
Hi, Perhaps I'm missing something simple, but ever since I enabled caching middleware in my apps, I've noticed that it's causing lots of strange behaviour in my admin: updates taking a while to show up, new objects not showing up, messages taking a while to filter through. I'm assuming it's

Re: Checking whether a Foreignkey object has been assigned to anything

2006-07-12 Thread Phil Powell
for c in Category.objects.all() if c.photo_set.count()] > > You could say that it is not very optimal because you are fetching all > the categories. But I personally wouldn't worry about it if there are > not many categories. > > Cheers, > Jorge > > On 7/12/06, Phil Powell <[EMAIL P

Re: FileBrowser Test Version

2006-07-12 Thread Phil Powell
om > path_to_file = '/media/img/filebrowser_Thumb.gif' > to > path_to_file = '/media/img/filebrowser/filebrowser_Thumb.gif' > > note: our hosting-provider has setup trac for us. so, hopefully we'll > have an SVN address soon. > > patrick > > Am 12.07.2006 um 14:01

Re: FileBrowser Test Version

2006-07-12 Thread Phil Powell
Thanks for the update Patrick. I've got this part working, but having trouble with makethumb on existing files on the server - not had time to delve too deeply yet to see what the problem is though. -Phil On 11/07/06, va:patrick.kranzlmueller <[EMAIL PROTECTED]> wrote: > > a new version of the

Re: FileBrowser Test Version

2006-07-11 Thread Phil Powell
This is fantastic stuff! I'll be taking a look at testing it out and possibly implementing for a current project (thousands of image files to manage). Any plans for a SVN address? -Phil On 08/07/06, patrickk <[EMAIL PROTECTED]> wrote: > > today we´ve finished the test version of our django

Re: Triple Store / RDF

2006-06-22 Thread Phil Powell
On 22/06/06, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > I guess mine was more of a combination. I wrote an interface that was > similar to the querying interface in Django at the time (0.90 / 0.91 > style). Give it keyword args of what to select and triples describing > the filtering

Re: Triple Store / RDF

2006-06-22 Thread Phil Powell
an object-based API translate to SQL without a middle-man? -Phil On 19/06/06, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > On Mon, 2006-06-19 at 12:35 +0100, Phil Powell wrote: > > Hi all, > > > > Just out of pure curiosity: has anyone had any experience / know of

Re: manipulating images

2006-06-20 Thread Phil Powell
It might be worth you taking a look at the work done on Thumbnails in DjangoUtils: http://djangoutils.python-hosting.com/wiki/Thumbnails Although not a solid chunk of code (there are a few issues with namespaces, and it uses some Python 2.4 specific stuff), but with a bit of hacking I got

Re: Existing database into django models?

2006-06-19 Thread Phil Powell
This ought to do the job: http://www.djangoproject.com/documentation/legacy_databases/ -Phil On 19/06/06, Mike Crowe <[EMAIL PROTECTED]> wrote: > > Hi folks, > > I'm just starting looking at a django backend for a system we need to > redo. The existing db is MSSQL (yes, I know it's not quite

Triple Store / RDF

2006-06-19 Thread Phil Powell
Hi all, Just out of pure curiosity: has anyone had any experience / know of any work around using RDF / triple stores with Django? -Phil --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To

Re: Processing Image on Save

2006-06-16 Thread Phil Powell
On 16/06/06, mwtb <[EMAIL PROTECTED]> wrote: > Okay, I haven't looked at that, so at least it's a new options, thanks. > My Python ability gets a bit stretched when reading some of the code in > that area, but I guess that's a good thing. I've just been playing around with creating new field

Re: Settings Model

2006-06-16 Thread Phil Powell
As far as I know, there's no way to restrict the number of instances of a particular model. You could hack the admin templates to hide "Add" buttons if an instance of a particular model already exists. Or override the save method in the model so that it doesn't save if an instance already

Re: Comment URLs hardcoded?

2006-05-24 Thread Phil Powell
And in addition, for anyone who's interested, if you change the default path from /comments/ for your commenting, you'll need this patch: http://code.djangoproject.com/ticket/1997 It will rectify an issue with posted forms redirecting to the wrong location. -Phil On 24/05/06, Phil Powell

Re: Comment URLs hardcoded?

2006-05-24 Thread Phil Powell
- this is what I'm finding great about Django: conventions allow you to make assumptions which just work! -Phil On 24/05/06, Phil Powell <[EMAIL PROTECTED]> wrote: > I just wanted to pose this question before raising a ticket, or > starting to work on a patch, just incase someone's got

Comment URLs hardcoded?

2006-05-24 Thread Phil Powell
I just wanted to pose this question before raising a ticket, or starting to work on a patch, just incase someone's got a workaround. I'm implementing contrib.comments, and everything works fine in a basic dev setup. However, I'm running into a problem when trying to deploy on a more complex

Re: How fix the "feature" of not serving static files?

2006-05-24 Thread Phil Powell
There's one very good reason why Django (and any other framework / CMS worth it's salt) deliberately avoids serving static files, and that reason is "performance". Your content serving mechanism should be about retrieving and manipulating content data, and performance can be haevily impacted if

Re: How to write a module level method rather than a instance method

2006-05-22 Thread Phil Powell
On 22/05/06, Carlos Yoder <[EMAIL PROTECTED]> wrote: > > Guys, let's try to cut down on cynicism, please? We all have our day > jobs, responsibilities, families and so on and so forth, and this is a > motivation-driven, heartfelt project. Hear hear. Malcolm is putting a lot of effort into

Re: Django and static files URLs

2006-05-17 Thread Phil Powell
Surely you don't need to have the entire absolute URL - an sbsolute URL can be defined by just ensuring a preceeding forward slash appears in your paths - for example: should change to: This will cause the resource to be referenced from the root of your domain. Alternatively, you can use a

Re: Dreamhost - does anyone know a better webhosting?

2006-05-16 Thread Phil Powell
I have been hosted with these guys: http://www.bytemark.co.uk/ for quite some time. I started out with them when they were a young startup, and I can highly recommend them if you're looking for "full control" solution. They are a UK-based company, and they provide a very reliable "Virtual

Re: ManyToManyField reverse lookup not working

2006-05-16 Thread Phil Powell
It may not be exactly related to the problem you're having, but worth checking: I was having some difficulty checking the right syntax for use when referencing many-to-many fields recently, and noticed that the syntax has changed from what is currently documented. You can find a chart

Re: Problems with setup of Django with Apache and mod_python

2006-05-12 Thread Phil Powell
Hi Gunnar,I had a few issues when setting up my first Django project through mod_python, the main tricky bit being the setup of the correct PythonPath variable.  However, seems you've got that right.The only other thing I can think of is that Apache doesn't have permission to access your Django

Re: Comment options not appearing in admin

2006-05-11 Thread Phil Powell
an Limberg <[EMAIL PROTECTED]> wrote: On 5/11/06, Phil Powell <[EMAIL PROTECTED]> wrote:> Thanks for the clarification - always useful while the documentation is in a> state of flux.> > I've now got the front-end comments working as expected, and I'm mightily> impressed with

Re: Comment options not appearing in admin

2006-05-11 Thread Phil Powell
osting acomment to that object:{% free_comment_form for blog.posts object.id %}You can find out more about how the comment tags work in thetemplatetags library in django.contrib.comments: http://code.djangoproject.com/browser/django/trunk/django/contrib/comments/templatetags/comments.pyOn 5/10/06

Comment options not appearing in admin

2006-05-10 Thread Phil Powell
HI all,I'm a relative newbie to django, but so far I'm mightily impressed (particularly with the speed of development).I've just run into my first serious problem when trying to get comments functioning though.  Here's what I've done: added 'django.contrib.comments' to my INSTALLED_APPSrun 'python