I currently have a working form for job tickets using django 2.0. I want to add the ability for multiple file uploads as supporting docs and assets. I can easily add this into the admin side of things using inlines, but how would I accomplish something similar on the front end of the site? I'm not sure how to have a form submit to two models when a key/id has yet to be set. I'm using primary keys to associate the files with the entries...
models.py:
class Job(models.Model):
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=200)
...
class File(models.model)
file = models.FileField(upload_to='uploads/%Y/%m')
job = models.ForeignKey(Job, models.set_NULL, blank=True, null=True)
admin.py
class FileInline(admin.TabularInline):
model = File
extra = 0
@admin.register(Job)
class JobAdmin(admin.ModelAdmin):
exclude = ['ticket_number']
inlines = [FileInline]
This system is great in my admin and in my templates, but I just can't figure out how to get these two to live in one form together. Is there a better way to be doing this?