By Akram


2019-08-13 20:04:33 8 Comments

I'm new to Django and I'm trying to build an eCommerce website, but I'm facing a problem of storing data of products that don't share the same attributes. I'm wondering which database technologies to use and how design database in such way that I could store different products attributes without problems.

1 comments

@Lucas Vazquez 2019-08-13 20:19:52

Django is good with RDB (Relationals Data Bases).

Dealing with undetermined data, you need to use JSON storage format because you don't know what attributes have the model. Non-Relationals Data Bases are good for that, but, RDB isn't. You can use MongoDB for storage that JSON info, but there born a new question:

When to use MongoDB with Django?

Short Answer: You don't.

Source: when to use mongodb with django

You can use Postgresql JSON field implementation in Django.

from django.contrib.postgres.fields import JSONField
from django.db import models


class Product(models.Model):

    metadata = JSONField(null=True, blank=True)

Related Questions

Sponsored Content

28 Answered Questions

[SOLVED] How do I check if a list is empty?

  • 2008-09-10 06:20:11
  • Ray Vega
  • 2547959 View
  • 3235 Score
  • 28 Answer
  • Tags:   python list

37 Answered Questions

[SOLVED] How do I check whether a file exists without exceptions?

41 Answered Questions

[SOLVED] How do I merge two dictionaries in a single expression?

21 Answered Questions

[SOLVED] How do I list all files of a directory?

  • 2010-07-08 19:31:22
  • duhhunjonn
  • 3760761 View
  • 3474 Score
  • 21 Answer
  • Tags:   python directory

25 Answered Questions

[SOLVED] How can I safely create a nested directory?

14 Answered Questions

[SOLVED] "Large data" work flows using pandas

34 Answered Questions

[SOLVED] How do I sort a dictionary by value?

Sponsored Content