Thanks, Larry for replying. I want to say I am new in Django and I 
don't know how to use in class-based view, Can you help me to 
integrate with CBV?

On Tuesday, September 18, 2018 at 5:57:28 PM UTC+5:30, larry....@gmail.com 
wrote:
>
> On Tue, Sep 18, 2018 at 8:13 AM, Django Lover <sunilk...@gmail.com 
> <javascript:>> 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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/dbe133d7-43ee-4765-b776-925214415ac3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to