On Tue, Sep 18, 2018 at 8:13 AM, Django Lover <[email protected]> wrote: > How i can update model when Key exist else create a new one?? > > > My code is- > > **Form.py** > > class UserSettingForm(forms.ModelForm): > class Meta: > model = StUserSetting > fields = ( 'default_language', 'prim_currency', 'number_format', > 'decimal_format', > 'date_format', 'time_format', 'currency_format', > 'currency_position', 'financial_year_start', > 'week_start', 'estimate_default_tab', 'invoice_default_tab',) > > **View.py** > > > class CreateUpadateUserSetting(LoginRequiredMixin, FormView): > template_name = 'settings/user_settings.html' > form_class = UserSettingForm > success_url = '/user/setting/preference/'
https://docs.djangoproject.com/en/2.1/ref/models/querysets/#update-or-create -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACwCsY4s9GQLrwkxRFKHe7LoNXB0SPkqmHEzTvmgZAozp0eowA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

