Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to add field to django forms createview

class MyModelCreateView(CreateView):
    model= My_model
    form_class = MyModelForm
    template_name = "application/mymodel.html"

    def form_valid(self, form):
    # comment: this fn will return the data from the HTML form 
    # and add to it the missing attrs of the model then save it
        form.instance.attr_1='string I want to save'
        #to save a clean string pass it between '' not ""
        form.instance.attr_2='a'
        return super().form_valid(form)
Comment

PREVIOUS NEXT
Code Example
Python :: Generate bootstrap replicate of 1D data that return a particular operation 
Python :: queue data structure in python 
Python :: heksadesimal ke ascii 
Python :: forward fill in pyspark 
Python :: Python RegEx Escape – re.escape() Syntax 
Python :: python secret module to generate secure strings 
Python :: dict get keys tcl 
Python :: np logical and 
Python :: how to select the three highest entries within a category in pandas 
Python :: dft numpy amplitude 
Python :: csv/gpd to shapefile python 
Python :: how to update only some fields in django serielizer update method 
Python :: convert matlab code to python 
Python :: python package for facial emotion recognition 
Python :: how to choose appropriate graph for your dataset visualization 
Python :: allow django imagefield accept base 64 image 
Python :: egt id of current object django 
Python :: Fill NaN with the first valid value starting from the rightmost column, then extract first column 
Python :: create horizontal descriptives table pandas 
Python :: run windows command and get output python 
Python :: python nc group variables 
Python :: change the surface color rhinopython 
Python :: re.add python 
Python :: houghlinesp python stackoverflow 
Python :: couchbase python 
Python :: dashbars detect first loop 
Python :: python censoring pypi 
Python :: python3 array 
Python :: one small letter three big bodyguard 
Python :: how to xor two element in python 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =