design_ui = models.CharField(max_length=255, default='')
design_document = models.FileField(upload_to='uploads/%Y/%m/%d/(Id like to put the instance design_ui here)', blank=True)
class GaasWaferDesignCreateView(LoginRequiredMixin, CreateView,): fields = ("design_ui", "emitting", "contact_location", "optical_power", "design_date", "designer", "design_document", "designer_ui", "in_trash", "inactive_date", "notes") model = GaasWaferDesign template_name = 'engineering/gaas_wafer_designs/gaas_wafer_design_form.html'
def form_valid(self, form): object = form.save(commit=False) object.created_by = self.request.user object.save() return super(GaasWaferDesignCreateView, self).form_valid(form)
def upload_path(instance, filename): return os.path.join('uploads/%Y/%m/%d/' + instance.design_ui, filename)
design_document = models.FileField(upload_to=upload_path, blank=True)
--
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...@googlegroups.com.
To post to this group, send email to django...@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/8173dbcc-8870-44d1-9796-e22b465144e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
def upload_path(instance, filename): return os.path.join('uploads/' + datetime.datetime.now().strftime('%Y/%m/%d/') + instance.design_ui, filename)