5đź‘Ť
I love django but there is an lot of it to get your head around! If you don’t want the database bit, focus on urls.py and views.py that will process your urls and return the info you want as an http response.
eg. urls.py
urlpatterns += patterns('myapp.views',
url(r'^getstuff/$', 'getstuff' ),
)
in views.py
def getstuff(request):
do whatever in python
return HttpResponse(stuff to return)
4đź‘Ť
You don’t need to use database in Django projects.
Basically django comes with some standardized architecture that follows MVC pattern (or MVT as sometimes described). This includes models, views, url dispatching, templates, etc.
Probably you need to do following things to accomplish your task:
- create url definition in urls.py
to some django view - write
django view that call somehow your
api and displays result as a web
page
you don’t need models and database at all but you need to get familliar with views, urls, templates. It might look like a big machinery for your simple case but if you have some time I encourage you to these django basics.
If you are looking for somethin much simpler I heard about webpy project. This might be better option if you need something really simple.
- [Django]-Resource temporarily unavailable: mod_wsgi (pid=28433): Unable to connect to WSGI daemon process
- [Django]-Django all-auth Form errors not displaying
- [Django]-Web Dev. Framework for RAD Web App Dev. in Shortest Time ( Yii vs. Django )
1đź‘Ť
An important question is: Do you want the web services to be provided by a full-featured server like Apache, or are you just looking at the “web server” to be a thread (or equivalent) in your program?
If you want to run Apache, then I’d recommend something like Werkzeug, which will handle most of the WSGI stuff for you. For templating, I’ve heard good things about Jinja2.
If that is too much, and all you want is a lightweight, simple server (something that, say, just spits out some HTML or XML when asked, and doesn’t need any fancy URL handling), you can use the SimpleHTTPServer or CGIHTTPServer modules that ship with Python.
Django is a full-featured, integrated package that provides almost everything you need to write database-backed web applications. While its various components can be used in isolation, if you’re only using one thing (the template and view engines, in your case), it is probably overkill.
- [Django]-What is a distributed messaging system? Specifically what is 'distributed' in it?
- [Django]-Import modules that are above project root
- [Django]-Django REST Framework's APIClient sends None as 'None'
1đź‘Ť
No need for a framework at all. Raw wsgi isn’t hard but a little verbose. So I like to use WebOb
Here’s Raw wsgi
def application(environ, start_response):
start_response("200 OK", [])
return ["<html><body><h1>Hello World</h1></body></html>"]
Here’s the webob version
from webob.dec import wsgify
from webob import Request
@wsgify
def application(request):
return Response("<html><body><h1>Hello World</h1></body></html>")
That’s enough to run under apache mod_wsgi, and there are plenty of libraries that you can use that expect/produce webob Request and Responses. Anything that Turbogears 2 or repoze.bfg uses is fair game at that point.
- [Django]-Django: ImportError: cannot import name 'GeoIP2'
- [Django]-JSON Response from Django in Android
- [Django]-Increasing number of initial forms in a Django formset based on data in POST?
- [Django]-How to lock access to django redis cache
- [Django]-Getting Django channel access in Celery task
0đź‘Ť
You definitely don’t have to use a database with Django. Whether it fits your needs, only you can tell. There are other Python web frameworks that you can use.
- [Django]-Python: two way partial credit card storing encrytion
- [Django]-Should I use Django's contrib applications or build my own?