Problems saving model objects

2009-07-02 Thread Michael Stevens
Hi. I've defined a model object (with a number of DecimalFields), and I can load it happily, but when I take a freshly loaded instance and call .save(), I get the error: TypeError: Cannot convert float to Decimal. First convert the float to a string I suspect this is because for some reason dj

Re: Problems saving model objects

2009-07-02 Thread Michael Stevens
I think I've worked it out now. I'd defined the field wrong (didn't match database type). It loaded fine, but when I tried to save the same data django rejected it. 2009/7/2 Shawn Milochik : > > Would you post the model and the relevant parts of the form and/or view? > > In any case, you can easi

django test db

2009-07-03 Thread Michael Stevens
Hi. Is there a nice way to use a separate db user when running tests? I don't want my main user to have to have permissions to do things like creating databases. I'm currently experimenting with doing something with a separate settings.py file but it doesn't feel nice. Michael --~--~-

Re: django test db

2009-07-03 Thread Michael Stevens
Rama - I know about TEST_DATABASE_NAME, but I want to use a different user as well. 2009/7/3 Boštjan Jerko : > > > On 3.7.2009, at 11:36, Michael Stevens wrote: > >> >> Hi. >> >> Is there a nice way to use a separate db user when running tests? >> &g

Re: django test db

2009-07-03 Thread Michael Stevens
Might work, feels a bit hacky though. Thanks, Michael 2009/7/3 Boštjan Jerko : > > > On 3.7.2009, at 11:36, Michael Stevens wrote: > >> >> Hi. >> >> Is there a nice way to use a separate db user when running tests? >> >> I don't want my main

problems with model formsets

2009-07-09 Thread Michael Stevens
Hi. I'm trying to use a model formset. I've successfully got it rendering data from the database and showing it on a form to edit, but I'm now trying to recreate the data in save. So I've got: FooFormset = modelformset_factory(Foo exclude = ['id', 'foo']) foo_formset = FooFormse

Re: problems with model formsets

2009-07-10 Thread Michael Stevens
I worked it out in the end - I had two formsets in the same form, and hadn't realised the need for the prefix option to separate them. 2009/7/10 Karen Tracey : > On Thu, Jul 9, 2009 at 12:01 PM, Michael Stevens > wrote: >> >> Hi. >> >> I'm trying to use

more formset adventures

2009-07-10 Thread Michael Stevens
Hi. I'm using a ModelFormset created with lineformset_factory. When I click delete on one of the records and save the formset, it successfully removes the associated db record, but if I redisplay the formset after the save, it's still showing the now removed form. I've modified my code to recre

removable file field?

2009-07-16 Thread Michael Stevens
Does anyone have a removable file field definition for django 1.1? I found http://www.djangosnippets.org/snippets/636/ which is exactly what I want but it seems to have the key flaw of giving server errors on current django. Michael --~--~-~--~~~---~--~~ You rece

Re: removable file field?

2009-07-16 Thread Michael Stevens
I found something that's working for me now: http://code.djangoproject.com/ticket/7968 Although I had to modify the save method slightly to add commit. 2009/7/16 Michael Stevens : > Does anyone have a removable file field definition for django 1.1? > > I found http://www.djan

passing parameters to formset

2009-09-15 Thread Michael Stevens
Hi. I'm creating a formset of forms using formset_factory. It's all working nicely, but I'd like to pass some values into the forms to use as the choices for one of the fields. Is there a way to do this? As far as I can tell the formset_factory takes over the creation of the form and I can't se

Verifying number of forms in inline formset

2012-03-05 Thread Michael Stevens
Hi. I've got a django app using an inline formset. It was all working nicely, but I want to add some validation such that the inline formset must contain at least one valid record. This seems to be surprisingly hard to do. I've tried overriding clean() on the formset and looking at things like