Thursday, October 31, 2013

Re: django - default value name for the ForeignKey

Thank you so much for your reply. But I am just a beginer, didn't quite understood the 'Manger' thing. Will you please be kind enough to elaborate a little more. Thank you.

On Thu, Oct 31, 2013 at 8:44 PM, Aamu Padi <> wrote:

I have a model for uploading photos in an album by the users. But if the user don't want to create an album, and just upload photos, I want it to be uploaded in a default album, namely 'Default album'. So that, whenever the user uploads photo without creating a new album, the 'Default album should be updated by that photos. For that, I thought about giving a default value in the title of the Album, but I also don't want to create a new album with name 'Default album' whenever the user doesn't create a new album to upload photo. I just want to update the 'Default Album'. Please suggest me how to achieve the above mentioned. And also is it okay to just give the ForeignKey field of the User to the Album class and not the Photo class??? Thank you!

class Album(models.Model):      title = models.CharField(max_length=200)      pub_date = models.DateTimeField(      user = models.ForeignKey(User)      class Photo(models.Model):      album = models.ForeignKey(Album)      title = models.CharField(max_length=200)      image = models.ImageField(upload_to=get_upload_file_name, blank=True)      pub_date = models.DateTimeField(

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
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment