lmb-embrapa / machado

This repository provides users with a framework to store, search and visualize biological data.
GNU General Public License v3.0
25 stars 14 forks source link

Registering all models in admin.py #335

Closed swrosati closed 2 years ago

swrosati commented 2 years ago

I am unable to see the models at :8000/admin. See image below.

I have followed the instructions to run: python manage.py inspectdb > unsortedmodels.py and fixChadoModel.py --input unsortedmodels.py

image

azneto commented 2 years ago

You don't need to execute those steps. As stated in the documentation (https://machado.readthedocs.io/en/latest/installation.html), machado already contains a copy of this file: models.py

If you followed the installation instructions (https://machado.readthedocs.io/en/latest/installation.html), the tables should have been created when you executed the python manage.py migrate. If you ran the python manage.py test machado and got no errors, you're good to go.

We haven't configured the admin interface at all, every new instance will show the same thing as in your screenshot. I suggest loading data using the data loading tools (https://machado.readthedocs.io/en/latest/dataload.html) and visualizing using the visualization tools (https://machado.readthedocs.io/en/latest/visualization.html).

swrosati commented 2 years ago

Thanks for the quick reply. I have data loaded into the app and love what I'm seeing on the front end! I may turn this into a feature request.

I find that the Django admin page is a great place for quickly reviewing entries (editing and when necessary). I'd find it really useful to be able to see the data via the django admin interface. It would help me get up to speed with all of the moving pieces and would help me manually adjust any data loading errors that may arise as I orient myself.

Thanks for all the hard work. This is a great resource!

azneto commented 2 years ago

I'm glad it's working out fine for you! Enabling the models for django admin should be pretty much straightforward (https://docs.djangoproject.com/en/4.0/ref/contrib/admin/). Alternatively, the software DbVisualizer (https://www.dbvis.com/download/) is a nice interface to the database for reviewing entries purposes.

In the near future, we have plans to implement web interfaces for the data loading tools, though I'm not sure whether the django admin interface would be the ideal place to host them. To be evaluated...

swrosati commented 2 years ago

Thanks for the input.

I have tried the Django 'standard' method of registering the models with admin, however, they still don't come up for some reason.

The admin.py below is the product of the fixChadoModel.py --input unsortedmodels.py command, and machado is registered as an app in settings.py. I have also confirmed that this path is where django is importing the models from.

tree -L 1 lib/python3.8/site-packages/machado-0.3.0-py3.8.egg/machado

lib/python3.8/site-packages/machado-0.3.0-py3.8.egg/machado ├── admin.py ├── api ├── apps.py ├── decorators.py ├── forms.py ├── init.py ├── loaders ├── management ├── migrations ├── models.py ├── pycache ├── schemas ├── search_indexes.py ├── settings.py ├── static ├── templates ├── templatetags ├── tests ├── urls.py └── views

I'll give DbVisualizer a shot. Thanks for the recommendation.

azneto commented 2 years ago

You don't need to execute those steps, take a look: https://machado.readthedocs.io/en/latest/models.html Such commands were used to generate the models.py file. The repository already contains the current version that matches the chado schema.

In order to configure the django admin, you should follow the instructions at https://docs.djangoproject.com/en/4.0/ref/contrib/admin/

Based on the first example of the documentation, I created this snippet of code to show the Db model:

admin.py

from django.contrib import admin
from machado.models import Db

class DbAdmin(admin.ModelAdmin):
    pass

admin.site.register(Db, DbAdmin)
swrosati commented 2 years ago

Thanks! That's helpful. I'm still experiencing some issues, but I think they may actually be related to interactions between models of Machado and Haystack. I will follow up shortly.

Thanks for your continued support!

azneto commented 2 years ago

Inactive for more than 10 days