Skip to content

Instantly share code, notes, and snippets.

View shalomz's full-sized avatar

Shalom Nyende shalomz

View GitHub Profile
@shalomz
shalomz / 01_models.py
Created February 8, 2018 11:25 — forked from dimi-tree/01_models.py
Django REST Framework: understaning ModelSerializer
from django.db import models
class Member(models.Model):
# RE: null vs blank
#
# NULL https://docs.djangoproject.com/en/1.10/ref/models/fields/#null
# Avoid using null on string-based fields such as CharField and TextField because
# empty string values will always be stored as empty strings, not as NULL.
#
@shalomz
shalomz / url_patterns.py
Created February 6, 2018 10:34 — forked from c4urself/url_patterns.py
URL Patterns with Optional Arguments
(r'^articles/(?P<year>\d{4}/?$, 'main.views.year'),
# When a use case comes up that a month needs to be involved as
# well, you add an argument in your regex:
(r'^articles/(?P<year>\d{4}/(?P<month>\d{2})/?$, 'main.views.year_month'),
# That works fine, unless of course you want to show something
# different for just the year, in which case the following case can be
# used, making separate views based on the arguments as djangoproject
@shalomz
shalomz / nagios
Created February 4, 2018 15:15 — forked from smukkejohan/nagios
Nagios with Nginx configuration
server {
listen 80;
server_name nagios.example.tld;
access_log /var/log/nginx/nagios.access.log;
error_log /var/log/nginx/nagios.error.log info;
expires 31d;
root /usr/share/nagios3/htdocs;