0

I'm (new to) working in Django and would like to create two features that do not rely upon models/database tables. The basis of this app is as a web-based wrapper to a Python application.

The features are:

  1. I would like to be able to load a ConfigObj text file into a page and edit it's configuration prior to saving again.
  2. I would like to be able to call command line python/bash scripts and display their output on a page - like exec in PHP.

At the moment I'm working on simple custom admin pages without model as described here:

Django admin, section without "model"?

Would this be the right direction to go in? I'm not sure proxy tables apply as the features I desire have nothing to do with any data.

So far I have looked at is it possible to create a custom admin view without a model behind it and a few other links. At the moment I have:

main/urls.py

url(r'^admin/weectrl', include('weectrl.urls')),

which links with weectrl/urls.py

from weectrl import views

urlpatterns = patterns('',
    (r'^admin/weectrl/manage/$', weectrl_manage_view),
    (r'^admin/weectrl/config/$', weectrl_config_view),
)

which points to weectrl/views.py

def weectrl_manage_view(request): 
    r = render_to_response('admin/weectrl/manage.html', context, RequestContext(request))
    return HttpResponse(r)

def weectrl_config_view(request):
    r = render_to_response('admin/weectrl/config.html', context, RequestContext(request))
    return HttpResponse(r)

The current error message is name 'weectrl_manage_view' is not defined

Community
  • 1
  • 1
Byte Insight
  • 745
  • 1
  • 6
  • 17
  • 1
    You need to split these two questions out into separate posts, and include what research you've done so far to try and resolve the problem. If you have code, even better. The more detail you provide, the better we can help. – Martijn Pieters Jan 17 '14 at 13:23
  • However, as it stands your question is both too vague and too broad to be answered. – Martijn Pieters Jan 17 '14 at 13:23
  • Martijn, thank you for your supportive comments. Hopefully, I have fine tuned this sufficiently to meet the required standard. If I can be assured I'm going in the right direction and maybe helped to overcome this initial hurdle that would give me something to work on. Thanks again. – Byte Insight Jan 17 '14 at 13:47
  • Ok, found something that works. In the main url.py url(r'^admin/weectrl/', include('weectrl.urls')), In app/urls.py urlpatterns = patterns('', url(r'^config/$', views.config, name='config'), url(r'^manage/$', views.manage, name='manage'), ) and in app/views.py def config(request): context = "" return render(request, 'weectrl/config.html', context) # Display/Get records for all time def manage(request): context = "" return render(request, 'weectrl/manage.html', context) html files are in app/templates/app/... – Byte Insight Jan 17 '14 at 21:16
  • You can create your own answer too; create a post below (there may be an initial time limit). – Martijn Pieters Jan 17 '14 at 21:18

1 Answers1

0

Ok, found something that works.

In the main url.py

 url(r'^admin/weectrl/', include('weectrl.urls')), 

In app/urls.py

urlpatterns = patterns('', 
  url(r'^config/$', views.config, name='config'), 
  url(r'^manage/$', views.manage, name='manage'),
) 

and in app/views.py

def config(request): 
  context = "" 
  return render(request, 'weectrl/config.html', context) 

def manage(request): 
  context = "" 
  return render(request, 'weectrl/manage.html', context) 

html files are in app/templates/app/...

Byte Insight
  • 745
  • 1
  • 6
  • 17