-
Notifications
You must be signed in to change notification settings - Fork 0
REST API
API root is located at /api/
Will return the API Root with links to the other endpoints of the api.
As of right now everything is in development
TODO: Specify the endpoints
- post road network:
- post production data:
- Retrieve road status for a given geographic area. How long since last time the road stretch was maintained and how much snow since last maintenance etc. (To be used for showing status on map.)
- Retrieve a stretch of road.
In backend/urls.py
include your api app's urls.py file.
urlpatterns = [
url(r'^', include('api.urls')),
...
]
This should be near the top of urlpatterns, because it is prioritized by order.
In your api/urls.py
file, the urlpatterns router include should be set to api/
urlpatterns = [
url(r'api/', include(router.urls))
]
See the Django and Django Rest Framework documentation for more informantion
A serializer allow complex data such as model instances to be converted to native Python data types that can be rendered into html or json. It also provide deserialization, allowing data to be converted back to complex data.
The Meta class has many different options that can be set.
The model option specifies which model this serializer uses (database model).
The fields option selects which fields from the model the serializer uses when serializing/deserializing.
Similar to serializers the models supports metadata.
The abstract option sets the model to be abstract. This can be used to make a template model with base fields if you want several of your models to have some of the same fields.
Example:
class BaseModel(models.Model):
id = models.AutoField(primary_key=True)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
class Meta:
abstract = True
Usage:
class ProductionData(BaseModel):
This will include the three fields of BaseModel in ProductionData. The id field is the primary key and will auto increment. It will (should) also make it so the created field is set to the date at which the row was created and the updated field should be set to the current datetime every time the row is updated. Fields with auto_now_add=True
and auto_now=True
also have editable=False
by default
-
Product related
-
Development process and guidelines
-
Sprints
-
Testing
-
-
Old notes