Python
Django Snippets
· β˜• 3 min read
1. Auto-Register All Models in Admin admin.py 1 2 3 4 5 6 7 8 9 10 # -*- coding: utf-8 -*- import inspect from django.contrib import admin from . import models for name, obj in inspect.getmembers(models): try: if inspect.isclass(obj): admin.site.register(getattr(models, name)) except Exception as e: pass 2. Get All View Names Get all view names of the project

Getting Started with Django REST Framework
· β˜• 2 min read
In the SaaS development I work on, there is a fairly high demand for development efficiency. From project initiation, prototype design and evaluation, requirements confirmation, frontend design, and backend development through to final acceptance, we complete one iteration in just a few weeks. Guided by agile development, we began rolling

Django Restful APIs with Tastypie
· β˜• 3 min read
1. Restful REST is short for Representational State Transfer, meaning “representation state transfer”. Restful is a development philosophy and a software architecture style for the World Wide Web. 1.1 Features of Restful Abstract resources Images, text, songs, and videos are all resource entities; on the network they are abstracted as

The manage Command in Django
· β˜• 2 min read
Every Django project automatically generates a manage.py file. manage.py is a simple wrapper around django-admin; its job is to put the Django Project into the sys.path directory and set the DJANGO_SETTINGS_MODULE environment variable to the current Project’s settings.py file. In other words, the difference between django-admin and manage is that

Meta Options in Django Models
· β˜• 4 min read
Define metadata for a model through an inner class “class Meta”, like this: 1 2 3 4 class Foo(models.Model): bar = models.CharField(max_length=30) class Meta: #...... Model metadata means: any data that is not a field such as ordering options, admin options, and so on. Below are all the Meta options you might use.