Thanks Furbee,
UNDERSTOOD.
Thanks again for detailled and instructive answers.
Alain
On 2 nov, 21:36, Furbee wrote:
> Hi Alain,
>
> Sort of. With this code:
> if field == 'category':
> instance.save()
> a Customer with 50 categories would write to the database 51 times (1
> INSERT,
Hi Alain,
Sort of. With this code:
if field == 'category':
instance.save()
a Customer with 50 categories would write to the database 51 times (1
INSERT, and 50 UPDATES).
Including the "instance.id == None" like this:
if field == 'category' and instance.id == None:
instance
Hi again
thanks for explanations.
I've understood difference between Null and None.
I've modify the code to add "instance.id == Non" and it seems to be
faster.
To be sure. You mean that if a customer has 1 category, there will be
2 database access (one for all informations except category and on
Hi Alain,
Glad that it worked out! :-)
To clarify, a blank is different from a Null, or "None" in Python/Django. A
blank character field is "" where a null character field is NULL. If a
field does not specify null=True, and you try to save an instance of that
object without specifying that field,
Oupsss, another question in the step by step:
1 class InscriptionWizard(SessionWizardView):
2 def done(self, form_list, **kwargs):
3 instance = Customer()
4 for form in form_list:
5 for field, value in form.cleaned_data.iteritems():
6 if field == 'categor
Hi Furbeenator,
thanks a lots, it works !!! :-)))
I've use your first solution. You say that "category would have to be
the first Allow Null field in your model" wich is not the case here. A
"phone" field is the first step (Step0) can be empty :
telephone = models.CharField(max_length=14, blank=Tr
In your Customer model there are fields which cannot be Null, so you cannot
instance.save() before setting those properties. So, you may have to check
for the category field in your loop and if it is category, save the
instance first. Something like the following:
views.py (in clients application)
Hello,
i'm currently doning a website where user can register (without
password, without auth module of Django). They put some informations
and at the end (Step5Form) do multiple choices by clicking on
checkboxes. When I click on validate on the last step I've "instance
needs to have a primary key
8 matches
Mail list logo