Home>
from django.db import models
class HisTube (models.Model):
title = models.CharField ('title', max_length = 100)
image = models.CharField ('thumbn', max_length = 200)
url = models.CharField ('Video URL', max_length = 200)
length = models.CharField ('length', max_length = 50)
cname = models.CharField ('channel name', max_length = 100)
curl = models.CharField ('channel url', max_length = 100)
I'd like to save the values intitleandimageof this models.py in view, but I don't know how.
-
Answer # 1
Related articles
- python - django doesn't show model for second project in admin tools
- python - i want django to reflect the value from view in the parent template
- python - i want to change the ip address that the django app gets by default from remote_addr to http_x_forwarded_for in middlew
- name error in underscore in python django
- javascript - i want to post using ajax in django and rewrite the db value
- i want to dynamically change the value of a variable in python and execute it
- python - object is not displayed in html in django queryset
- python - about image deletion in django
- i want to set the maximum value of the slider in python to the number entered in the text box
- python - how to output the key and value in the dictionary in any form
- python 3x - how to get the value of scrolledtext
- python - django image folder reasons to create static and madia folders separately
- python - i want to use asyncio with django custom commands
- i want to get the value from a constant in python and display it
- python - django i want to filter the data associated with a foreign key and display it in a template
- put the maximum value of the list of variables in the objective function with python pulp
- python - vscode: i can't debug django apps
- python 3x - i want to save the value of a variable in memory
- python - judgment if the value is nan or not a valid url
- python 3x - the output result of the numerical value obtained by web scraping becomes 0
Related questions
- python : How to write a decorator to check custom permissions
- python : Celery. A large number of tasks in the queue
- python : Django question, namespace
- python : Django Select a valid choice. That choice is not one of the available choices when creating a form
- python : Django How can I pass a variable from views.py that contains text to an html template?
- python : Django error "NOT NULL constraint failed" while saving to database
- python : Django question, code problems
- python : Can't get two tasks running in celery in parallel
- python : ValidationError Django 3 not showing
- python : How to catch the crashed /not running dramatiq worker error?
I'm sorry for what I made, but there is a way like this.
https://github.com/Hayashi-Yudai/HouseKeepingBook/blob/277805d24b00bdb413cc6f5372aa0f9e7bf0d191/moneybook/templates/moneybook/mainview.html#L50
mainview.html
Specify post in the method of theform tag. And in the form element, you can receive data by making
{{form.used_date}}
like the code above. See form.py for the neighborhood.The part that receives this is written in view.py.
https://github.com/Hayashi-Yudai/HouseKeepingBook/blob/277805d24b00bdb413cc6f5372aa0f9e7bf0d191/moneybook/views.py#L51
For example, create a method named
post
and specify request as an argument. Then you can receive the contents of the form withrequest.POST
, and then you can access the contents using the method used in the Python dictionary. When saving to the database, use (model name) .object.create (view.py line 64).