Y
Y
Yura Khlyan2016-01-04 16:35:16
Django
Yura Khlyan, 2016-01-04 16:35:16

Error while validating the form. What's wrong?

Good day.
From my previous questions, it will be clear that I am trying to make 5 stores with one database on Django-Oscar. I have already done almost everything (divided the models by sites), but I just can’t separate the Offers model between sites. To be more precise, I changed the models (added the Site field, changed the managers), then it remained to change the Forms in the Dashboard.Offers application (Oscar admin panel).
Added the Site field to the form:

if settings.SITE_ID == -1:
    SITE_INITIAL = None
    SITE_WIDGET=forms.Select()
else:
    SITE_INITIAL = Site.objects.get_current().id
    SITE_WIDGET=forms.HiddenInput()


class MetaDataForm(OscarMetaDataForm):
    site = forms.ModelChoiceField( 
        queryset=Site.objects.all(),
        widget=SITE_WIDGET,
        initial=SITE_INITIAL)

    class Meta:
        model = ConditionalOffer
        fields = ('site', 'name', 'description')

Well, then I changed a few more methods in views.py (since there were several bugs). And everything works, but ...
They did the creation of Promotion through the Wizard, that is, step by step. And they take/record all the information about the Offer in the session. And the choice of the site for which the Offer is intended, I made at the first step of the Wizard. When I filled in all the required fields in the first step, it gives the second step, but when they return to the first step from the second step, there are errors on the form:
81c3993ab9014a48bc0ecfb3782d9dbd.png
But, despite these errors, I can still save the form, or proceed to the next step.
Who can tell what is the problem? I will be very grateful for your help.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question