These are chat archives for django/django

7th
Apr 2017
Khalil Preview
@khalilpreview
Apr 07 2017 12:59
hi guys i need some help
John
@flyboy1565
Apr 07 2017 14:06
Just post on here.. people in here will help when they have time
jainsahil1997
@jainsahil1997
Apr 07 2017 20:13
class Material(models.Model):
    dept_name=models.ForeignKey(Department,on_delete=models.CASCADE,blank=True, null=True)
    def filepath (self):
        return self.dept_name
    code=ChainedForeignKey(Subject,
                            chained_field="dept_name",
                            chained_model_field="dept_name",
                            show_all=False,
                            auto_choose=True,
                            sort=True,
                            on_delete=models.CASCADE)
    type= models.CharField(max_length=50,choices=Material_CHOICES,default='books')
    material_desc=models.CharField(max_length=50,blank=False,null=False,default='code')
    material_link=models.CharField(max_length=1000,blank=True)
    material_file=models.FileField(blank=True)
how do i upload the files in folder according to selected dept_name?