Tag Archives: django-admin

Django – Show model objects in Django Admin and apply format filter

We can easily scaffold the persisted objects list, add and delete pages on Django Admin by registering your model in your app admin.py file. For example, an app named eureka with model Person.

eureka/models.py

from django.db import models

class Person(models.Model):
  name     = models.CharField(max_length=256)
  homepage = models.URLField(max_length=256)

  def __unicode__(self):
    return self.name

 

eureka/admin.py

from django.contrib import admin
from eureka.models import Person

admin.site.register(Person)

Continue reading Django – Show model objects in Django Admin and apply format filter

Django – Create custom django-admin command

We could manage our Django project by executing some commands which could be invoked through the manage.py. For example:

# Sync database
python manage.py syncdb

# Start the webserver
python manage.py runserver 0.0.0.0:8000

 

Not only this built-in commands, we can write our own command too.

1. Create a new Django project and in this example i called it custom_command. (Django 1.6.5)

django-admin.py startproject custom_command

Continue reading Django – Create custom django-admin command