pip install -r requirements.txtpython manage.py migratepython manage.py createsuperuser --email [email protected] --username adminpython manage.py loaddata file1 file2 (after loaddata add required seed file names separeated by space). Seed files are found in ./seeddata folder.python manage.py runserver or to make accessible through LAN use python manage.py runserver 0.0.0.0:8000 and add your LAN IP to ALLOWED_HOSTS in the settings.py along with localhost. ( ALLOWED_HOSTS = ["localhost", "192.168.8.160"])backend directorydocker-compose builddocker-compose upbackenddocker-compose exec djangoapp python manage.py makemigrationsdocker-compose exec djangoapp python manage.py migratedocker-compose exec djangoapp python manage.py createsuperuserdjango inserts an auto-increment 'id' field by default. Unless you want to change it to something more meaninful or different, keep it
for small strings use, models.CharField
Foreign key referencing -> name the FK field as the object
ex: Book refering to Author ir Book.author (not Book.author_id)
Can have one FK to refer to multiple models, check Event model for example
Serializers are like services
We can select which fields to show and which ones to neglect in API responses
fields = "__all__" means you expose ALL fields and all fields are required to POST data as well
fields = ['field1', 'field2'] is a better option
Best would be to write custom serializers tho kek
Make sure the serializer output is camelCase (as opposed to snake_case used in the database). This is for better compatibility with the frontend. For this, if a certain field name needs to be converted it can be done. Refer EventSerializer (affectedAttribute field) for an example
Can have additional fields with serializers as well
django.core.exceptions.ImproperlyConfigured: The included URLconf 'src.urls' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.
This usually means your file being imported has some error, type or something. It can literally mean an error somewhere in the code, don't know why it pops up.
All responses have the same structure. This is enforced centrally, no need to change anything. Make sure to use the Response object to return responses than sending out manual ones.
{
message: str,
data: Object,
errors: [],
status: str
}
Services contain the domain model / business logic
Paradigm is thin view, thin model but fat service
If there's a reusable logic that involves more than one query to models, send it out to a service method.
Different apps should ONLY communicate through services. Donot invoke view methods of other apps directly
Public user creates incident Get assigned to HQ coordinator
Coodinator HQ creates incident Get assigned to ownself
Coodinator in Division creates incident Get assigned to ownself
Data Entry in Division with coordinator creates incident Get assigned to coodinator in own division
Data Entry in Division without coordinator creates incident Get assigned to coordinator in HQ
Police user creates incident Get assigned to coordinator in HQ Police user is added as a linked individual
Coordinator with manager escalates Get assigned to same division manager
Coordinator without manager in same division escalates Get assigned to HQ manager
Only users with CAN_CHANGE_ASSIGNEE can change the assignment
Refered entity is added as a linked individual
Content type
Image
Digest
Size
429.2 MB
Last updated
almost 7 years ago
docker pull lsflk/incident_api