Sunday, August 20, 2017

Questions About ModelForm

I am trying to create a form for a django-viewflow workflow. I have 2 models, Document and DocumentOCR as shown:

class Document(models.Model):
    document_id = models.AutoField(primary_key=True)
    document_category = models.IntegerField(category=DOCUMENT_CATEGORY)
    document_state = models.IntegerField(state=DOCUMENT_STATE, default=PRIVATE)
    documentType_id = models.ForeignKey(DocumentType, on_delete=models.CASCADE,)
    title = models.CharField('title', max_length=200)
    description = models.TextField('description')
    created = models.DateTimeField(editable=False)
    updated = models.DateTimeField(editable=False)
    storage_file_name = models.FileField('File name', upload_to=unique_file_path)
    original_file_name = models.CharField(editable=False, max_length=200)
    computed_sha256 = models.CharField(editable=False, max_length=64)
    
class DocumentOCR(models.Model):
    document_id = models.ForeignKey(Document, on_delete=models.CASCADE,)
    text_file_name = models.FileField('File name', upload_to=unique_file_path)
    text = models.TextField()

Documents are uploaded and saved to the local drive through the admin portal. That works. The workflow is used to review those documents that have text in them (DOCUMENT_CATEGORY), and for a user to decide if they can be OCRed and the text saved in the text field of the DocumentOCR model, or if they need to be transcribed by the user into the text field. Some of the documents are hand written notes that have been scanned into a pdf.

The first stage of the workflow is supposed to show a table with one document per row. The first cell has a radio button, and each succeeding cell has information from the fields in the Document and DocumentOCR tables. The user selects the document he/she wants to work on by clicking on the appropriate radio button.

Is there something in the ModelForm class that will create this table, or do I have to create the HTML for this table. From my reading, I gather I need to put the database query for the data set for the table in the view and pass that to the form. Is that the appropriate way to do something like this?

Thanks,

Mark

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEqej2PEVPdKuAkFDPqYz%2BRjytVnVQZb6K7UNGXz%2BQtHDGeyUg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment