
#VISUAL PARADIGM FOREIGN KEY UPDATE#
ĭjango.db.utils.IntegrityError: insert or update on table "pages_product" violates foreign key constraint "pages_product_parameter_id_3408a183_fk_pages_pro"ĭETAIL: Key (parameter_id)=(1) is not present in table "pages_productparameter".

I'm setting up the defaults to 1, because these rows must get something to fill out the columns in the existing rows, but when migrating it throws an error. Return reverse('product_detail', kwargs=) Image = ProcessedImageField(upload_to='products', Parameter = models.ForeignKey(ProductParameter, default=1, on_delete=models.CASCADE, related_name='products') Name = models.CharField('name of product', max_length=50) Parameter_type = models.ForeignKey(ProductParameterType, default=1, on_delete=models.CASCADE, Name = models.CharField('name of parameter', max_length=50, default=1) Name = models.CharField('name of type', max_length=50, default=1)Ĭlass ProductParameter(TimeStampedModel): Yeah, makes perfect sense now! Is this the way? class ProductParameterType(TimeStampedModel): Maybe if I added another table called Parameter? Thanks Need someone to tell me, if there is a better way or this is just fine. Is this a correct approach? I have been going through it for days already. I made for each single parameter a separate model like Fabric, Entrance, Paint, ProductSupport so in the detail view on my website you see if there are any parameters pointing to the selected product so that way I can list rows in each parameter as well like Paint has "black", "white", "brown" etc. Now each product has a specific set of parameters but they are repeated, logically.

Product has one picture as a profiling picture, the rest of images is placed in ProductImage model. just like a gallery and the rest is discussed with a customer. Like I know that a foreign key is a column that branches out to rows in another column, but when the table it points to consists of another foreign key, my head is about to explode xDįor example I am building an eshop but without prices, carts, payments etc.

Maybe even some typical examples would help. I can make a functional DB, but I want to do it well, normalized. I never really know, what to set as defaults.
#VISUAL PARADIGM FOREIGN KEY HOW TO#
I am kinda unable to see how to models are going to work together until I test it in the admin interface, only then it makes sense, but it's just highly ineffective and I had to completely wipe out the whole DB and re-do it again many times because I broke something when creating migrations. I seem to have a really hard time when trying to visualize in my head what I need to do to. Hi guys, so I was wondering if there were any online tool, or your favourite method how to design DB tables/Django Models and relations between them.
