I am trying to add a boolean field which is 'is_featured' column in a pivot table of Portfolio.
I want to add images gallery with multiple images but among them there will be a featured image or first one will be featured if there is more than one images is featured.
I have found that by 'through' is possible only if a reference table exist but that does not solve my problem when i want to a extra static column.
http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships
from django.db import models
from tinymce.models import HTMLField
from category.models import Category
from imageGallery.models import ImageGallery
from tag.models import Tag
class Portfolio(models.Model):
title = models.CharField(max_length=191)
description = HTMLField()
category = models.ForeignKey(Category, on_delete=models.CASCADE)
tag = models.ManyToManyField(Tag, blank=True)
gallery = models.ManyToManyField(ImageGallery, blank=True) # > Here I want to add another column 'is_feature' !!!!
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
Generally gallery will create a pivot table portfolio_portfolio_imageGallery where,
1. I want add another column 'is_feature' that could be nullable, or a boolean
2. and is it possible to have a checkbox, or text field for 'is_featured' column when i choose an image from admin
table detail,
id
portfolio_id
imageGallery_id
is_feature <- is extra column I want to add. Any help will be greatly appreciated.