Skip to content

Instantly share code, notes, and snippets.

@lovesh
Last active November 7, 2019 19:37

Revisions

  1. lovesh renamed this gist Jul 25, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. lovesh created this gist Jul 25, 2013.
    19 changes: 19 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    """
    Here models are in different modules and the models.py imports them from different modules like this

    from model1 import * # or the name of models you want to import
    from model2 import User

    or you might write all your models in models.py
    """


    from django.db.models.base import ModelBase
    from django.contrib import admin
    import models


    for model_name in dir(models):
    model = getattr(models, model_name)
    if isinstance(model, ModelBase):
    admin.site.register(model)