Re: Making an object unsaveable ...

2018-03-07 Thread Bernd Wechner
James, Thanks, that's really well put. I've implemented an override, and better still I love that with a model mix in I can override the save method on the object. Sort of like: class MyMixIn: def check_stuff(self) ... if ...: self.save = self.disabled_save

Re: Making an object unsaveable ...

2018-03-07 Thread Bernd Wechner
Melvyn, Just preference. Nothing more. Fix the issue at its source so all views that exist or might exist honor the demand basically. One model, many views. Regards, Bernd. On Tuesday, 6 March 2018 19:13:42 UTC+11, Melvyn Sopacua wrote: > > Hi Bernd, > > On zondag 4 maart 2018 10:41:52 CET

Re: Making an object unsaveable ...

2018-03-06 Thread James Bennett
The only way to guarantee a model is unsaveable is to do it at the database permission level. You can override methods on the model in your Python code to make it *harder* to save, but you can't make it impossible, because of how Python works. Consider the following simplified pair of classes:

Re: Making an object unsaveable ...

2018-03-06 Thread Melvyn Sopacua
Hi Bernd, On zondag 4 maart 2018 10:41:52 CET Bernd Wechner wrote: > Here is the use case: > > 1. Load an object from database > 2. Flag it as unsaveable, not to be written back to database under any > circumstances > 3. Make changes to the object (its fields) > 4. Present a detail view

RE: Making an object unsaveable ...

2018-03-05 Thread Matthew Pava
Behalf Of bill.torcaso Sent: Monday, March 5, 2018 8:48 AM To: Django users Subject: Re: Making an object unsaveable ... On Sunday, March 4, 2018 at 4:43:06 AM UTC-5, Bernd Wechner wrote: An interesting question I've not been able to solve reading docs or Googling. As every posting here

Re: Making an object unsaveable ...

2018-03-05 Thread bill.torcaso
On Sunday, March 4, 2018 at 4:43:06 AM UTC-5, Bernd Wechner wrote: > > An interesting question I've not been able to solve reading docs or > Googling. As every posting here only after some serious research efforts > including class inspections ;-). But am stumped and wonder if anyone else > ha

Re: Making an object unsaveable ...

2018-03-04 Thread Derek
I think the second case is more manageable; I'd actually have a second table that has an exact duplicate structure of the first. Then you can save your newly changed copy into that -- and delete the record just afterward, or even much later, if you need to. I cannot imagine a scenario in wh

Re: Making an object unsaveable ...

2018-03-04 Thread Bernd Wechner
Thanks Dan, I was actually thinking also last night of: 3. Override the save() method on the model. Not tested, not sure how robust, but as it happens there's a hook there already as all the models I'm work with have it overridden with tiny method that updates some admin fields like last_updat

Re: Making an object unsaveable ...

2018-03-04 Thread Dan Tagg
Two possibilities spring to mind 1. Don't grant django's database user the right to update the relevant table. If you take this approach you'll need to catch any errors if anyone writes code to attempt to do this 2. Use signals to catch any save attempts. This is easily circumvented. On 4 March

Making an object unsaveable ...

2018-03-04 Thread Bernd Wechner
An interesting question I've not been able to solve reading docs or Googling. As every posting here only after some serious research efforts including class inspections ;-). But am stumped and wonder if anyone else has any ideas. Here is the use case: 1. Load an object from database 2. Flag i