Hello, I'm trying to build a photo upload path which corresponds to the selected user i.e., when the user is selected from the drop down the username gets appended to the file upload path dynamically. If you have any ideas I would like to hear them:
class Listing(models.Model): user = models.ForeignKey(User, unique=True) user_directory_path = os.path.join(settings.MEDIA_ROOT, 'listings', user) user_directory = models.FilePathField(path=user_directory_path, recursive=True) photo = models.ImageField(upload_to=user_directory) name = models.CharField(max_length=50) order = models.ForeignKey('Order') def __unicode__(self): return self.name I keep getting this error: AttributeError: 'ForeignKey' object has no attribute 'startswith' --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---