Unfortunately, this doesn't work without a primary key needed for many-to-
many relations that are used in the model.
Previous tip with modifying base fields before instantiating a form
object works better.
On Tue, 24 Jul 2007 22:37:06 +, Patrick wrote:
> Seems like an elegant and logical
Seems like an elegant and logical solution. Thanks, Michael!
On Tue, 24 Jul 2007 21:04:50 +, Michael wrote:
> When I came across the same issue (model default values not being
> selected), I simply stopped using form_for_model for new forms and
> instead created an instance of my model in me
When I came across the same issue (model default values not being
selected), I simply stopped using form_for_model for new forms and
instead created an instance of my model in memory then used
form_for_instance... for eg:
p = Post()
PostForm = form_for_instance(p)
That way the default values for
On Tue, 24 Jul 2007 11:51:36 -0700, Doug B wrote:
> I don't know how others have approached it, but I have a 'settings' file
> with defaults defined in one place and reference those values via
> imports in the form file and model file. For values specific for the
> app, I stick them in the model
I don't know how others have approached it, but I have a 'settings'
file with defaults defined in one place and reference those values via
imports in the form file and model file. For values specific for the
app, I stick them in the models file.
models.py
-
POST_DEFAULTS = {'status':'pub
Hi!
I'm starting to use newforms for most of my forms, but I run into a
problem, which I'm hope has a DRY solution, but I haven't found it yet.
Here's my model chunk:
class Post(models.Model):
status = models.CharField(
maxlength = 15,
6 matches
Mail list logo