I am trying to modify the django admin interface and I cannot see the custom templates.
In the admin.py file I added this model admin
class FTPAdmin(admin.ModelAdmin):
def get_urls(self):
urls = super(FTPAdmin,self).get_urls()
my_urls = patterns('',
(r'^ftp/$',self.admin_site.admin_view(self.FTPView)))
return my_urls + urls
def FTPView(self, request):
form = FTPForm()
if request.method == 'POST':
if form.is_valid():
return HttpResponseRedirect('/admin/')
return render_to_response(request,'ftpform.html',{'form':form})
In my project folder I have a template folder with an admin subfolder with the custom template (/DjangoProjects/projectftp/templates/admin/ftp.html)
{% extends "admin/base_site.html" %}
{% block title %}My test upload{% endblock %}
{% block content %}
<form action="" method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Upload" />
</form>
{% endblock %}
In my settings.py file I change the template dir:
TEMPLATE_DIRS = (
BASE_DIR + '/templates/',
)
In my forms.py I create a simple form:
class ProcFTPForm(forms.Form):
anio = forms.IntegerField(required=True)
mes = forms.IntegerField(required=True)
def __init__(self, *args, **kwargs):
super(ProcFTPForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
I try to see the template in the url "ip:port/admin/ftp" or ip:port/admin/app_name/ftp or ip:port/ftp.
Any suggestion
Thanks in advance
UPDATE
this is the code of my model:
class Lectura_FTP():
def leer_ftp(self):
cursor = connection.cursor()
sp = cursor.callproc("CARGA_LISTA_ARCHIVOS_PC")
cursor.close()
return sp