title: Storing dynamic data in django
body: <p>So, in my application I currently am receiving and storing some data,the structure currently is based around this:</p>
  <ul>
  <li>Each application has a number of devices</li>
  <li>Each device has incoming data from its sensors</li>
  <li>Each sensor has a type (e.g. temperature/humidity/etc)</li>
  </ul>
  <p>Initially, I had wanted to find a solution to store the data dynamically into one table for all data, with a model that might look like this:</p>
  <pre><code>time = models.DateTimeField()
  sensor = models.ForeignKey(Sensor, on_delete=models.CASCADE)
  data = ???
  </code></pre>
  <p>Now, each sensor is connected in the models to all the details (including the application, the sensor hardware information and other API-related information for connecting to said sensors), however, for the data I looked up a number of options but I have yet to find one that feels sufficient, some of the options I explored are:</p>
  <ol>
  <li><p>Storing the data in a dictionary and storing that in a model as per the answers in <a href="https://stackoverflow.com/questions/402217/how-to-store-a-dictionary-on-a-django-model">Here</a></p>
  </li>
  <li><p>Having separate tables and somehow calling the models later when storing data using the method <a href="https://stackoverflow.com/questions/4881607/django-get-model-from-string">here</a>, in addition to some system with inheritance such as discussed <a href="https://dev.to/zachtylr21/model-inheritance-in-django-m0j" rel="nofollow noreferrer">here</a></p>
  </li>
  <li><p>Something similar to <a href="https://stackoverflow.com/questions/2506136/storing-dynamic-fields-in-django-forms">this</a> using dynamic fields</p>
  </li>
  </ol>
  <p>I am currently using mySQL, and I saw some other solutions that might work using PostgreSQL for example, but I would like to avoid switching databases if there is another option.</p>
  <p>I just feel there must be a better more clean solution for this, as it feels like a straightforward implementation. In a sense most of those implementation either feel too hack-y and inefficient especially considering that I will be storing a large amount of data (A larger number of sensors sending data continuously to the server), or do not allow queries on the sub-data.</p>
  <p>Are there any other better implementations for my application? If not, which one of those implementations is best for me to focus on?</p>