[Django]-Retrieve data from a table and register it as a model on Django's admin page

2πŸ‘

βœ…

Since this table is created and populated by APscheduler, I don’t have access to it as a Django model instance.

You have. django-appscheduler [GitHub] is just a Django app, and it has a models.py file [GitHub] with a DjangoJob in it.

You thus can import this with:

from django_apscheduler.models import DjangoJob

and make queries just like you do with another model.

2πŸ‘

Probably you can try like this: first, Create a model named Job with fields same as column name. Then in the meta, define the db_table field as Jobs and add managed = False:

Class Job(models.Model):
    field_one = models.IntergerField(primary_key=True)
    ...

    class Meta:
       db_table = 'Jobs'
       managed = False

In that way, you do not have to run migrations/migrate, and you should be able query using that model class.

πŸ‘€ruddra

Leave a comment