1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Rename PrimaryModel to NetBoxModel

This commit is contained in:
jeremystretch
2022-01-26 20:57:14 -05:00
parent a795b95f7e
commit c5650bb278
20 changed files with 66 additions and 64 deletions

View File

@@ -2,7 +2,7 @@
## 1. Define the model class
Models within each app are stored in either `models.py` or within a submodule under the `models/` directory. When creating a model, be sure to subclass the [appropriate base model](models.md) from `netbox.models`. This will typically be PrimaryModel or OrganizationalModel. Remember to add the model class to the `__all__` listing for the module.
Models within each app are stored in either `models.py` or within a submodule under the `models/` directory. When creating a model, be sure to subclass the [appropriate base model](models.md) from `netbox.models`. This will typically be NetBoxModel or OrganizationalModel. Remember to add the model class to the `__all__` listing for the module.
Each model should define, at a minimum:

View File

@@ -65,9 +65,10 @@ Simply subclass BaseModel when defining a model in your plugin:
```python
# models.py
from netbox.models import BaseModel
from django.db import models
from netbox.models import NetBoxModel
class MyModel(BaseModel):
class MyModel(NetBoxModel):
foo = models.CharField()
...
```
@@ -78,7 +79,7 @@ If you prefer instead to enable only a subset of these features for a plugin mod
```python
# models.py
from django.db.models import models
from django.db import models
from netbox.models.features import ExportTemplatesMixin, TagsMixin
class MyModel(ExportTemplatesMixin, TagsMixin, models.Model):