0
I’m a beginner in Django and I’m picking up a lot on one thing. I want to submit a form that has already been filled out for another table. I need somehow to select which table the form will be sent, and that it "go" with all the data that has already been inserted later.
Every time a new form is created, it goes to the home page:Note that the information has already been entered. I want to take the same information, select the Model Class, and send to the selected one.
I plan to make a kind of pendencia system to send to other people/ sectors.
My Models.py:
from django.db import models
from django.contrib.auth.models import User
class Solicitacao(models.Model):
nome = models.CharField(max_length=100)
carteira = models.CharField(max_length=17)
atendimento = models.CharField(max_length=100)
descricao = models.TextField()
data_da_solicitacao = models.DateTimeField(auto_now_add=True)
active = models.BooleanField(default=True)
user = models.ForeignKey(User, on_delete=models.CASCADE)
email = models.EmailField(null=True, blank=True)
telefone = models.CharField(max_length=100, null=True, blank=True)
arquivo = models.FileField(upload_to='documentos/%y/%m/%d/', null=True, blank=True)
def __str__(self):
return str(self.id)
class Sala1(models.Model):
nome = models.CharField(max_length=100)
carteira = models.CharField(max_length=17)
atendimento = models.CharField(max_length=100)
descricao = models.TextField()
data_da_solicitacao = models.DateTimeField(auto_now_add=True)
active = models.BooleanField(default=True)
user = models.ForeignKey(User, on_delete=models.CASCADE)
documentos = models.FileField(null=True, blank=True)
email = models.EmailField(null=True, blank=True)
telefone = models.CharField(max_length=100, null=True, blank=True)
arquivo = models.FileField(upload_to='documentos/%y/%m/%d/', null=True, blank=True)
def __str__(self):
return str(self.id)
class Sala2(models.Model):
nome = models.CharField(max_length=100)
carteira = models.CharField(max_length=17)
atendimento = models.CharField(max_length=100)
descricao = models.TextField()
data_da_solicitacao = models.DateTimeField(auto_now_add=True)
active = models.BooleanField(default=True)
user = models.ForeignKey(User, on_delete=models.CASCADE)
documentos = models.FileField(null=True, blank=True)
email = models.EmailField(null=True, blank=True)
telefone = models.CharField(max_length=100, null=True, blank=True)
arquivo = models.FileField(upload_to='documentos/%y/%m/%d/', null=True, blank=True)
def __str__(self):
return str(self.id)
class Sala3(models.Model):
nome = models.CharField(max_length=100)
carteira = models.CharField(max_length=17)
atendimento = models.CharField(max_length=100)
descricao = models.TextField()
data_da_solicitacao = models.DateTimeField(auto_now_add=True)
active = models.BooleanField(default=True)
user = models.ForeignKey(User, on_delete=models.CASCADE)
documentos = models.FileField(null=True, blank=True)
email = models.EmailField(null=True, blank=True)
telefone = models.CharField(max_length=100, null=True, blank=True)
arquivo = models.FileField(upload_to='documentos/%y/%m/%d/', null=True, blank=True)
def __str__(self):
return str(self.id)
View.py: In the view I have no idea what to make it work.