Skip to content

Instantly share code, notes, and snippets.

@rtpm

rtpm/django.py Secret

Last active November 22, 2016 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtpm/129c15e940001281a0d2421a936617f6 to your computer and use it in GitHub Desktop.
Save rtpm/129c15e940001281a0d2421a936617f6 to your computer and use it in GitHub Desktop.
django admin inline problem
#models.py
class Gallery(models.Model):
name = models.CharField("My Gallery", max_length=100)
class Photo(models.Model):
photo = models.ImageField("Photo", upload_to="/some/location/")
gallery = models.ForeignKey(Gallery)
#admin.py
class PhotoInlineOptions(admin.TabularInline)
model = Photo
class GalleryAdminOptions(admin.modelAdmin):
inlines = [PhotoInlineOptions]
@rtpm
Copy link
Author

rtpm commented Nov 22, 2016

Problem:
In a gallery instance changeView, when I add a new inline file (Photo) in the inlines, a new Gallery is created when "save and continue" button,
instead of adding new Photo to existing Gallery.

@rtpm
Copy link
Author

rtpm commented Nov 22, 2016

Solved. The problem was a custom save() Gallery method not mentioned in this gist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment