Re: Model - Only allow One

2008-06-17 Thread bruno desthuilliers
On 16 juin, 22:23, ocgstyles <[EMAIL PROTECTED]> wrote: > The client wants certain parts of the site to be editable, I don't > particularly agree with the logic, simply because why take a DB hit > (although small) just to grab text from a database for an "About" page > when that text us USUALLY

Re: Model - Only allow One

2008-06-17 Thread Daniel Hepper
If you just want an editable "about" page, the flatpages app might do what you want. http://www.djangoproject.com/documentation/flatpages/ Regards, Daniel Am Montag, den 16.06.2008, 13:23 -0700 schrieb ocgstyles: > The client wants certain parts of the site to be editable, I don't >

Re: Model - Only allow One

2008-06-16 Thread Rishabh Manocha
Why not just override the save method for the model and delete any instances of it before calling super.save(). I'm not a 100% sure on this, but I do think the admin interface calls the model save method whenever you edit something from there. So, something like this: class About(models.Model):

Re: Model - Only allow One

2008-06-16 Thread Dan Lazewatsky
The way you described has the added advantage of effectively keeping a version history. However, if no one is ever going to use this history it's just a waste of space. There are two other options I can think of, one probably better than the other: 1. Django's cache framework

Re: Model - Only allow One

2008-06-16 Thread ocgstyles
The client wants certain parts of the site to be editable, I don't particularly agree with the logic, simply because why take a DB hit (although small) just to grab text from a database for an "About" page when that text us USUALLY static. So thinking of this "About" page, maybe the client just

Re: Model - Only allow One

2008-06-14 Thread Andrew Ingram
bruno desthuilliers wrote: > Anyway, why would you want such a thing ? I can think of one possible use, when you want some project settings to be configurable at run-time through the admin interface. At the moment I would probably relate a settings model to the site model, but I think the site

Re: Model - Only allow One

2008-06-14 Thread bruno desthuilliers
On 14 juin, 15:53, ocgstyles <[EMAIL PROTECTED]> wrote: > Is there a way create a restriction that will only allow one instance > of a model? The closest you could get would be to define a model with a unique not editable field and override the save method to make this field a constant value.

Model - Only allow One

2008-06-14 Thread ocgstyles
Is there a way create a restriction that will only allow one instance of a model? For example, if I have a model called Zebra, is there a way I can have the Admin interface only allow one Zebra? (In other words, the Add Zebra link will not be visible in the Admin interface. Keith