I'm very new to the Django framework. I've started working with models and forms in django. I'm facing a problem in storing values to a database.
I want to get something like this.
from django.db import models
class attempt(models.Model):
name = models.TextField(max_length=200)
department = "Software Development"
Now I want to store the variable department in the database. Where for every entry of object of attempt name will be entered by the user but department remains the same.
And is stored something like the below-given format in the database
id: 1
name: "John Shelby"
department: "Software Development"
Edit 2: Now can I do something like this:
from django.db import models
class attempt(models.Model):
name = models.TextField(max_length=200)
def function1(str):
return(str+" Hello World")
x = function1(name)
department = models.Charfield(max_length=100,default=x,editable=False)
models.FileField(). And I have the code to extract the data from it. But I have no clue how to save it into the database.