django call admin.site.register from view -


i try register model admin site view.py, model's admin interface appear after go matching url. when go matching url model's name without reference appears, models instances doesn't display. it's necessary register model views.

models.py

from django.db import models  class poll(models.model):     question = models.charfield(max_length=200)     pub_date = models.datetimefield('date published') 

views.py

from django.contrib import admin django.shortcuts import redirect polls.models import poll  def index(request):     admin.site.register(poll)     return redirect('/admin') 

solution:

from django.contrib import admin polls.models import poll django.http import httpresponse django.shortcuts import redirect django.core.urlresolvers import clear_url_caches django.utils.importlib import import_module django.conf import settings  def index(request):     admin.site.register(poll)     reload(import_module(settings.root_urlconf))     clear_url_caches()     return redirect('/admin') 

Comments

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -