def register_views(app_name, view_filename, urlpatterns=None):
    """
    app_name       APP名
    view_filename  views 所在的文件
    urlpatterns    url中已经存在的urlpatterns

    return urlpatterns
    
    只导入View结尾的，是类的视图
    """
    app_module = __import__(app_name)
    view_module = getattr(app_module, view_filename)
    views = dir(view_module)
    for view_name in views:
        if view_name.endswith('View'):
            view = getattr(view_module, view_name)
            if isinstance(view, object):
                if urlpatterns:
                    urlpatterns  += patterns('',
                            url(r'^(?i)%s/$' % view_name, view.as_view(),  name=view_name),
                            )
                else:
                    urlpatterns = patterns('',
                            url(r'^(?i)%s/$' % view_name, view.as_view(),  name=view_name),
                            )
            else:
                pass
    return urlpatterns
def register_views(app_name, view_filename, urlpatterns=None):
    """
    app_name       APP名
    view_filename  views 所在的文件
    urlpatterns    url中已经存在的urlpatterns

    return urlpatterns
    
    只导入View结尾的，是类的视图
    """
    app_module = __import__(app_name)
    view_module = getattr(app_module, view_filename)
    views = dir(view_module)
    for view_name in views:
        if view_name.endswith('View'):
            view = getattr(view_module, view_name)
            if isinstance(view, object):
                if urlpatterns:
                    urlpatterns  += patterns('',
                            url(r'^(?i)%s/$' % view_name, view.as_view(),  name=view_name),
                            )
                else:
                    urlpatterns = patterns('',
                            url(r'^(?i)%s/$' % view_name, view.as_view(),  name=view_name),
                            )
            else:
                pass
    return urlpatterns
def register_views ( app_name , view_filename , urlpatterns = None ) : app_module = __import__ ( app_name ) view_module = getattr ( app_module , view_filename ) views = dir ( view_module ) for view_name in views : if view_name . endswith ( 'View' ) : view = getattr ( view_module , view_name ) if isinstance ( view , object ) : if urlpatterns : urlpatterns += patterns ( '' , url ( r'^(?i)%s/$' % view_name , view . as_view ( ) , name = view_name ) , ) else : urlpatterns = patterns ( '' , url ( r'^(?i)%s/$' % view_name , view . as_view ( ) , name = view_name ) , ) else : pass return urlpatterns
app_name       APP名
    view_filename  views 所在的文件
    urlpatterns    url中已经存在的urlpatterns

    return urlpatterns
    
    只导入View结尾的，是类的视图
app_name APP名 view_filename views 所在的文件 urlpatterns url中已经存在的urlpatterns