Application that uses Django models need to be a Django app? - python

What is the definition of a Django application? Any application that uses Django features, such as orm and url-view mapping?
I ask because I have a component which has 2 sub-components: a web service server and a standalone application. The web service server uses Django views to map url to request handlers. The web service server and the application use Django models and a database managed by Django. The web service server obviously needs to be a Django application. The standalone application must be a Django application as well?
Thanks in advance.

No, importing your models is enough, as long as you have Django installed and correctly configured.

Related

How to use Django with PGBouncer?

I have an application launched in Django, which has a very high traffic of requests and queries to the databases. I am having problems and I have read that with PGBouncer and some settings in Django I can solve the problem.
The question is how to integrate PGBouncer with Django.
I have the Django application in Docker.
The database is Postgres and it is in the RDS service of Amazon web services.
Would PGBouncer be installed on the instance where the Django application runs?

Django Rest Framework + Django CAS

I've been tasked with adding CAS authentication to an existing Django app which uses the Django Rest Framework.
Using django-cas library I'm able to authenticate via CAS to the admin features of the Django framework, but I'm not sure how to go about authenticating the Django rest framework app via CAS; it's still authenticating via some custom authentication logic that the original developers added. If anyone has any insight or experience with this it would be much appreciated.

How to use pyramid cookie to authenticate user in tornado web framework?

In a server, I have a pyramid app running and I plan to have another tornado app running in parallel in the same machine. Let's say the pyramid app is available in www.abcd.com, then the tornado app will be available in www.abcd.com:9000.
I want only the authenticated users in the pyramid webapp to be able to access the tornado webapp.
My guess is somehow using cookie set by the pyramid app in tornado.
Is it possible? What is the best way to do that?
The two locations are separate origins in HTTP language. By default, they should not share cookies.
Before trying to figure out how to pass cookies around I'd try to set up a front end web server like Nginx that would proxy requests between two different backend servers. Both applications could get their own path, served from www.abcd.com.

Dynamically deploy django admin app

I've recently started my python/django walkthrough and there's still a question that bothers me: I dont find a really easy, unobtrusive, painless way to deploy a Django app =(. I only see tutorials of mod_python, fastCGI, wsgi stuff - all of them are necessary for each webapp I create..
I'm used to Java web-apps (JSF+Tomcat) and I'm used to just drop the *war package in the webapps folder. Or uploading the *war through tomcat-manager. Or, even better, make a maven-hot-remote-deploy. And as far as I'm concerned, simple PHP apps also need minimum config (after setting up the apache2 conf, just cp the php-webapp-folder to /var/www/ would do..). I cant believe that Python lacks this kind of feature =((
My point is: after a clean OS install (let's take a JEE-VPS for example), I only need do setup my web server once. If I develop the webapp01, I choose one of the options above to deploy it. When I develop my webapp02, the same thing - no need to change tomcat-some-conf.xml to deploy it after webapp01. Obviously I consider only small webapps, like Django admin ones. =]
My target is to setup a Python/Django webserver and dynamically create Django admin webapp's, automatically hot deploying them to the webserver. So, I'd initially setup the web server stuff once and have a ready http://myserver.com. When user A generated a webappA01, it would be transparently available in http://myserver.com/userA/webappA01.
Is it possible?
Modern approach is to use uwsgi with Apache or NGINX (I recommend this one).
I don't know a tool which will auto-deploy your Django app. There are many web services like Heroku which deploy your app automatically (you supply just your VCS repository).
You can deploy your Django app semi-automatically by writing some scripts that will sync your code base, apply migrations for the db and reload web server. Check fabric or Buildbot.
First, Python/Django does not provide a "drop-in" deploy function by themselves, nor I know any way of doing something similar to war packages.
There are services that provide easy deploy methods like Heroku, but I recommend reading Django's official documentation about deploying for starters.
My target is to setup a Python/Django webserver and dynamically create
Django admin webapp's, automatically hot deploying them to the
webserver. So, I'd initially setup the web server stuff once and have
a ready http://myserver.com. When user A generated a webappA01, it
would be transparently available in
http://myserver.com/userA/webappA01.
Sounds like what you want to do can be accomplished with custom AdminSite instances.
Basically, you can write a view that instantiates an AdminSite instance named "webapp" (you can pull those parameters from the url of course, and check if the webapp data exists on the database). You'll need to connect any models you want to that AdminSite instance either from that view or by overriding its init method. The autodiscover function of the Django admin may not work for custom admin sites.

B2B App authentication on GAE - Google Accounts or custom user base (Django or Web2Py)?

Which of these would you pick for a B2B app (targeting small/med-small businesses) built on GAE with python:
Google Accounts
Custom Users with Django
Custom Users with Web2Py
I'm very tempted to go the Google Accounts route as it's very well integrated into GAE and takes care of everything from user creation to session authentication, and even takes care of forgotten passwords. However, I'm sure there are significant drawbacks to this, including usability, but if you are starting from scratch, which approach would you pick and why?
I started with Google account, added all OpenID and quickly found that the only accounts people use for my site are google and facebook accounts. So now I only have login with google and login with facebook. But I'm going to add my own accounts and I'm doing it with webapp2 instead of django and instead of web2py. I tried web2py but webapp2 and its auth model seem much better and not like with web2py a lot of unnecessary code that is not for app engine.
Try this and its auth model (there is example code from http://code.google.com/p/webapp-improved/issues/detail?id=20) and I hope it will work for you.
Google Accounts forces users to have Google Apps or Gmail accounts. Some customers might not like this.
Rolling your own is an (unnecessary) burden: you have to have sign up process (with captcha and/or 3rd party email confirmation), keep all user records, handle the security, etc..
I'd suggest you go with OpenID: http://code.google.com/appengine/docs/python/users/overview.html#Authentication_Options
Why both Create Django user from Google users. you will be able to adapt your system user with other system next
I've understood that question was only on authentication after I've written this so most of things here are offtopic, but I just wanted to demotivate on using full-stack solutions like django or web2py in appengine.
I can tell you something about django because I've used it for over a year and I do like it for certain types of websites. It was first framework which I've tried to use on appengine and I've dropped it after two weeks.
These are things in django which doesn't work or make no sense in appengine:
django models and orm: designed for sql; appengine sdk has its own models.
django admin site: is designed for sql databases, doesn't work on appengine
auto-forms from models: designed for django models
django management commands: none of commands which come with django is useful when working with appengine SDK.
django development server: appengine sdk has its own development server, django's one does not work.
django "plugable apps" architecture: at least in my practice it was useless on appengine.
static files collector: great tool to collect static files from various reusable applications into one folder, only if you have many reusable applications.
There exists django-nonrel project which says it can run django with admin site on appengine. It can, with half of things working and a lot of bugs. You spend more time trying to fix what does not work than building things.
What might be useful from django framework:
django forms: can be exchanged for a better library WTForms
django url routing: can use Werkzeug instead
django request/response objects and HTTP exceptions: can use Werkzeug instead
django pretty-printing exceptions: Werkzeug does it better, it adds a web debugger.
django i18n and localization: can be changed with babel
django templates: jinja2 is similar and a lot faster, which is important because appengine is an expensive platform. ctypes module is required to debug errors in jinja templates, however ctypes is forbidden on appengine, but on development server it does work, for debugging you don't need more.
Actually Jinja2, Werkzeug, WTForms and babel are so cool, that there exists projects for each of them which integrates them with django.
I know two frameworks which use these libraries:
kay-framework: made for appengine, a bit outdated, but a great example how you can use Jinja2, babel and Werkzeug on appengine.
flask from Armin Ronacher, the man behind Werkzeug and Jinja2.
I've not used web2py, however since it is also a full-stack framework like django is, I think it will be as bad as django is. Full-stack solutions simply do not fit in this different environment. Simple libraries fit in any environment.

Categories