model definition - admin only

Django: 5.1.1
python: 3.12.5

I have never needed to do this before.
I have searched the forum and of course online and nothing.

Question 1:
I need to create a new database model that will only be edited in Django admin. It will be accessed in various apps, but not edited. Where do I define the model at? When it’s for an app I define it in the local models.py. This model is not app specific. So where do I define it?

Question 2:
Usually when you define a model that you want access to in Django admin you reference it in the apps admin.py file. Since this is only edited in Django admin where do I reference it at? What admin.py file would that be in?

Question 3:
Based on your answer(s) above would I reference that location only from any app I need to read data from in this model?
i.e.: from app_name.models import ManagerMessaging

sample model class name
class ManagerMessaging(models.Model):
:slight_smile:

Models are models. It doesn’t matter how they’re used, they’re always defined and accessed the same way.

How you use those models are up to you. There’s nothing preventing you from creating a model that is only used by the admin. It’s still going to be defined in a models.py file in an app.

Structurally, there will be nothing different about this model from any other model you define.

Hi Ken,
So can I define a models.py file at the project level and only use that for these types of needs? I don’t even see an admin.py file there. if not where do u suggest it should go based on your experience?

Thank you
John

No, they still need to be defined in an app.

Same as your admin.py

There is no difference in how you create models based upon how they’re being used. (You could even define a model that isn’t used anywhere in your project. It doesn’t change how those models are managed.)