#NEWLINE# def create_view( views_name , views_type , template_name , model_name = False ) : #NEWLINE# #INDENT# with open ( 'views.py' , 'a+b' ) as view_file : #NEWLINE# #INDENT# if model_name : #NEWLINE# #INDENT# view_file . write ( bytes ( 'from models import {} \n' . format ( model_name ) , 'UTF-8' ) ) #NEWLINE# #UNINDENT# if is_class_based ( temp_id ) : #NEWLINE# #INDENT# temp_id = 'cbv_views' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# temp_id = 'views' #NEWLINE# #UNINDENT# template = string . Template ( open ( return_template ( temp_id ) ) . read ( ) ) #NEWLINE# variables = { #NEWLINE# #INDENT# 'VIEWNAME' : views_name , #NEWLINE# 'TEMPLATENAME' : template_name , #NEWLINE# #UNINDENT# } #NEWLINE# result = template . substitute ( variables ) #NEWLINE# view_file . write ( bytes ( result , 'UTF-8' ) ) #NEWLINE# view_file . close ( ) #NEWLINE# #UNINDENT# return