django


save postgres arrayfield using modelform


I have a model with ArrayField and I want save data using ModelForm. But my problem is every time only the first value from array is saving . How do I save whole array from form ? Here is my code:
model:
class Reminder(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
active = models.BooleanField(default=True)
provider_type = (
('Em', 'Email'),
('Sm', 'SMS'),
('De', 'Desktop'),
('Mo', 'Mobile'),
)
notification = ArrayField(models.CharField(choices=provider_type, max_length=2, default='Em'))
form:
class ReminderForm(ModelForm):
class Meta:
model = Reminder
exclude = ('user', )
view:
def create(request):
if request.method == 'POST':
reminder_form = ReminderForm(request.POST)
if reminder_form.is_valid():
form = reminder_form.save(commit=False)
user = get_object_or_404(User, username=request.user.username)
form.user = user
form.save()
else:
.....
return redirect('create')
return render(request, 'add.html')

Related Links

django pagination by giving textbox inputs
Django many to many filter by ALL in list
Form.is_valid() returns true when it shouldn't?
django error on importing class from model
Neo4Django - How to define relationships dynamically?
Deploying Mezzanine on Heroku
Django Raising Runtime Errror
Wagtail Image template tags
No Reverse Match Why?
Where is Break button in Dell Inspiron 15R
django-rest-framework and swagger api documentation
django-cms picture plugin - bulk upload
puppet - exec command in virtualenv context
Remove (filter out) objects from queryset
A model with a defined field throws an AttributeError when accessing it
including extra field in django userena profile

Categories

HOME
notepad++
twitter-bootstrap-3
awk
codenvy
c99
fpga
amp-html
datastore
static
yahoo-finance
spring-data-redis
replace
tivoli
regular-language
tvos
nuget-package
google-cloud-datalab
frontend
elasticsearch-5
arangodb
radgridview
selectize.js
event-sourcing
topology
user-experience
kendo-mobile
ios10.2
postscript
joptionpane
short-url
highstock
resourcebundle
beta
opentk
syntax-highlighting
jquery-multiselect
bulletphysics
subclass
user-defined-functions
tizen-tv
userdefaults
login-script
lubridate
protege4
gdata
p4merge
odoo-website
http-request
android-checkbox
importerror
apache-spark-dataset
fwrite
clarifai
chai-as-promised
facebook-pixel
context-switch
video-conferencing
qtranslate
backbone-collections
ngmaterial
vibrate
donations
pytables
reporting-services-2012
synonym
android-wake-lock
createprocess
halcon
invoke-sqlcmd
kendo-upload
toast
design-principles
asyncdisplaykit
jbase
opl
java-money
fiware-monitoring
oracle-spatial
jdi
text-search
visual-sourcesafe-2005
slash
apache-commons-daemon
packet-sniffers
raygun
mintty
extjs2
koala
mt4j
hidapi
mvc-editor-templates
abstract-data-type
jquery-1.9
asplinkbutton
curb
qi4j
pstack
jquery-blockui
xcode3.2
cross-database
stress
node-redis
gobject-introspection
entity-attribute-value
user-tracking
saxparseexception
filemerge
entitydatasource
quotation-marks
delimited-text
object-database
feasibility

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile