mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
Update adding-models.md to reflect changes to get_absolute_url
This commit is contained in:
parent
99904c1518
commit
572aad0e20
@ -8,7 +8,7 @@ Each model should define, at a minimum:
|
|||||||
|
|
||||||
* A `Meta` class specifying a deterministic ordering (if ordered by fields other than the primary ID)
|
* A `Meta` class specifying a deterministic ordering (if ordered by fields other than the primary ID)
|
||||||
* A `__str__()` method returning a user-friendly string representation of the instance
|
* A `__str__()` method returning a user-friendly string representation of the instance
|
||||||
* A `get_absolute_url()` method returning an instance's direct URL (using `reverse()`)
|
* A `get_absolute_url()` method if necessary; a standard version of the method is defined in the `NetBoxFeatureSet` base class, but you will need to provide your own (returning an instance's direct URL using `reverse()`) if not subclassing that base class
|
||||||
|
|
||||||
## 2. Define field choices
|
## 2. Define field choices
|
||||||
|
|
||||||
@ -78,6 +78,8 @@ Create the following for each model:
|
|||||||
|
|
||||||
Create a GraphQL object type for the model in `graphql/types.py` by subclassing the appropriate class from `netbox.graphql.types`.
|
Create a GraphQL object type for the model in `graphql/types.py` by subclassing the appropriate class from `netbox.graphql.types`.
|
||||||
|
|
||||||
|
**Note:** GraphQL unit tests may fail citing null values on a non-nullable field if related objects are prefetched. You may need to fix this by setting the type annotation to be `= strawberry_django.field(select_related=["policy"])` or similar.
|
||||||
|
|
||||||
Also extend the schema class defined in `graphql/schema.py` with the individual object and object list fields per the established convention.
|
Also extend the schema class defined in `graphql/schema.py` with the individual object and object list fields per the established convention.
|
||||||
|
|
||||||
## 14. Add tests
|
## 14. Add tests
|
||||||
|
Loading…
Reference in New Issue
Block a user