I'm about to create a new custom Django app for my organization. (I'm a brand new Django developer; this will be my first one apart from the occasional "Hello world" I've done as a prototype.)
I'm on a shared hosting provider, which indicates that for Django applications, we should use Django version 1.8 (even though 1.10 is the current version) because 1.8 is the last version that supports FastCGI. Am I setting myself up for having a worthless app a few years from now once 1.8 is no longer supported? Would one expect that by the time 1.8 is no longer supported, the shared web hosting world will have moved on to WSGI or some form of workaround? Or is that a fundamental impossibility? Will I find in a couple of years that I've developed an application that is unusable on the host I've produced it for?
Alternatively, should I be considering some other development tool for the situation I'm in? I'm on a shared host, and I'll be doing a fairly vanilla web front end / database back end style setup.
Am I setting myself up for having a worthless app?
Nope. You will have your project working, and if you ever want to upgrade and find it difficult to jump 3 version at once (1.8 LTS to 1.11 LTS) you can do it step-by-step with neat deprecation warnings. Though general compatibility between versions is usually very good. You will probably also want to have requirements.txt to recreate your virtualenv, and then just dropping away the fcgi trash.
... the shared web hosting world will have moved on to WSGI ...?
They will have to if they want to earn money. It is also quite easy to configure so there's no other "fundamental impossibility" than laziness.
Should I start a new Django app with version 1.8?
I cannot decide for you. I would rather consider changing my hosting. On the other hand there's handful of popular extensions that didn't successfully migrate their master to 1.10 yet (e.g. grappelli), which could also cause delayed migration of your own projects.
Should I be considering some other development tool?
Too general. Ever seen Flask? It's neat, but Django comes with more features out of the box.
Related
I depend a lot on the Webbapp2 Framework to build my web apps and find it to currently be my easiest(favorite) alternative to others like Django & Flask because it integrates seamlessly with the python API for Google app engine.
I am however very worried of the fact that;
the twitter(#webapp2) last tweeted in 2011.
there is no active GitHub repo for webapp2 maintained by Google and yet Google code is turning READ ONLY!.
no new release version since 2011!
Those three reasons above have led me to think that the Project is Abandoned and might be killed eventually.
Since webapp2 (just as its predecessor webapp) was designed primarily/specifically for the GAE Python sandbox I think it's safe to assume it (or a reasonably similar replacement, if any) will remain alive for as long as GAE Python sanbox will.
Should at some point Google will decide to retire or replace it I presume they will also, as usual, provide early official notifications and ample time for migration to an alternate suggested solution before the apps relying on it will stop working.
I'd interpret the lack of activity on its codebase simply a sign of the code's quality and maturity.
WRT the Google Code going read-only it's really just a step in discontinuing Google's service of hosting sw projects, it doesn't mean development of those projects stops altogether. Development will be migrated to better project hosting services:
http://google-opensource.blogspot.ca/2015/03/farewell-to-google-code.html
So I've been tasked with upgrading a Django server from 1.6.2 to the latest (~1.8), along with upgrading Python from 2.7.3 to 3.3. I suspect this is going to break quite a bit of code. (I even need to upgrade the Ubuntu installation from 12.04 to 14.04)
I would like to migrate my Django app from the server it's currently running on (Ubuntu 12.04) to a virtual machine, and use that environment as a sandbox to make changes.
Would anyone be so kind to provide guidance on django app migration? Please let me know if you'd like me to provide any specific details.
Thank you.
Edit: If anyone would like to vote down this question because they believe I haven't done enough research, I'm very happy to add missing information, if I know what you're looking for.
Django versions from 1.5 onwards has been designed so that the same code will work on both versions of Python as in the documentation thanks to them following the six compatibility layer.
You might face some issues with code that isn't strictly related to Django components like print statements and other such parts that might have been coded in. The official Python Porting Guide should held you with that.
Django 1.8 is a LTS (Long Term Release) so it's a good idea to upgrade to it. Migrating the database might be a bit of an issue considering it's from 2.7 to 3.4 but that's in all likelihood the place you'll find most issue with. The How to Migrate is a great resource.
If I recall correctly the directory structure is a bit different in 1.6 so you'll have to move some code and files manually. I suggest having the tutorial pages for both versions 1.6 and 1.8 open and comparing the directory structure.
Going through the first 2 pages of the tutorial should give you enough of an overview to migrate the database and the settings file. This should also help with migrations.
The 3rd and 4th pages should get you through migrating the views and urls files.
The only thing I'm not familiar with is the migration of the wsgi file which has configuration information, you should be able to find some basic information about that here.
Updating your Ubuntu however won't change or affect anything at all.
Also as has been said in the comments by jape and joel, it's a good idea to use virtualenv and git.
I would like to add another suggestion based on my own experience with pushing code to a Django server :
Download the code base to your local machine and work there and once you're done and the server is working well on your machine push it all to the server at once. That way you can isolate server machine specific issues from coding issues.
I have been looking at setting up a web server to use Python and I have installed Apache 2.2.22 on Debian 7 Wheezy with mod_wsgi. I have gotten the initial page up and going and the Apache will display the contents of the wsgi file that I have in my directory.
However, I have been researching on how to deploy a Python application and I have to admin, I find some of it a little confusing. I am coming from a background in PHP where it is literally install what you need and you are up and running and PHP is processing the way it should be.
Is this the same with Python? I can't seem to get anything to process outside of the wsgi file that I have setup. I can't import anything from other files without the server throwing a "500" error. I have looked on Google and Bing to try to find an answer to this, but I can't seem to find anything, or don't know that what I have been looking at is the answer.
I really appreciate any help that you guys can offer.
Thanks in advance! (If I need to post any coding, I can do that, I just don't know what you guys would need, if anything, as far as coding examples for this...)
Python is different from PHP in that PHP executes your entire program separately for each hit to your website, whereas Python runs "worker processes" that stay resident in memory.
You need some sort of web framework to do this work for you (you could write your own, but using someone else's framework makes it much easier). Flask is an example of a light one; Django is an example of a very heavy one. Pick one and follow that framework's instructions, or look for tutorials for that framework. Since the frameworks differ, most practical documentation on handling web services with Python are focused around a framework instead of just around the language itself.
Nearly any python web framework will have a development server that you can run locally, so you don't need to worry about deploying yet. When you are ready to deploy, Apache will work, although it's usually easier and better to use Gunicorn or another python-specific webserver, and then if you need more webserver functionality, set up nginx or Apache as a reverse proxy. Apache is a very heavy application to use for nothing but wsgi functionality. You also have the option of deploying to a PaaS service like Heroku (free for development work, costs money for production applications) which will handle a lot of sysadmin work for you.
As an aside, if you're not using virtualenv to set up your Python environment, you should look into it. It will make it much easier to keep track of what you have installed, to install new packages, and to isolate an environment so you can work on multiple projects on the same computer.
Installed Django 1.5 python2.7 mod_wsgi and python-sql on a red hat 4 web server with apache 2.
The "It worked" page keep flipping between the correct display and "internal server error" "500"
The flip occurs very frequently when pressing F5, but not only when quickly sending a request.
I have restarted Apache, erased wsgi that was configured for python 3.2 and reconfigured and installed for 2.7. I have also tried creating a new project, mysql database, and kicking the cat < not advisable.
On the python 3.2 installation I was having problems with the admin page registrations flipping between what I had applied, and being non-existent.
This error is occurring with debug = true, no apps installed, no database configuration yet, and what I assume is a complete baseline system aside from the wsgi file which seemed to work fine for the 3.2 installation.
If you are getting issues with the Python egg cache, see the mod_wsgi documentation at:
http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Access_Rights_Of_Apache_User
The reason it flicks may be because you are running a multiprocess configuration and so requests can go to different processes. That it would be different though for different processes is a bit odd, but is often explained by import order dependencies in your code where whether it works depends on the order in which URLs are visited.
Quite often such ordering issues don't show up if using Django and developing with Django developer server, because the Django development server preloads code before requests are handled. I have commented on this specific Django issue in:
http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html
Do note that code examples in that corresponded to an old Django version so may not be appropriate to use now.
I am wondering how to go about implementing a web application with Python.
For example, the html pages would link to python code that would give it increased functionality and allow it to write to a database.
Kind of like how Reddit does it.
If you're looking for server side programming with databases and html templates etc, I think Django is great, along with Pyramid. However, I use Flask ( http://flask.pocoo.org/ ) for this since it is easy to use, learn and deploy even though it may not have as much support as the before mentioned 2 framework since it's just a microframework, using the Jinja2 templating engine, including a development test server with it's own debugger.
On the other hand, if you're going for client-side programming (i.e. in browser implementation ) You can look up .NET Ironpython or even Brython which uses python like javascript.
You might want to check out mod_wsgi or mod_python.
What Is mod_wsgi?
The aim of mod_wsgi is to implement a simple to use
Apache module which can host any Python application which supports the
Python WSGI interface. The module would be suitable for use in hosting
high performance production web sites, as well as your average self
managed personal sites running on web hosting services.
-
Current State of Mod_Python
Currently mod_python is not under active development. This does not
mean that it is "dead" as some people have claimed. It smiply means
that the code and the project are mature enough when very little is
required to maintain it.
This is a good article from the Python website:
http://docs.python.org/howto/webservers.html
Plain CGI is a good starting point to learn about server side scripting, but it is an outdated technology and gets difficult to maintain after certain level of complexity. I would think it is no longer used in industrial-grade web server anymore. Plus you have to setup a web server and then install some module to interpret python script (like Apache with mod_python) just to get started.
I had some experience with Django (https://www.djangoproject.com/) and found it fairly easy to get started with since they come with development test server. All you need to have is a Python interpreter + Django and you can get up-and-running quickly and worry about the deployment setup later. They have pretty good documentation for beginner as well.
We have never used Python for a web site without a framework. In our case that is Django. In other words, we do not use Python for our web sites the way Perl can be used, just having Apache run a Perl script.
The recommendations you have received about Django are sound. If you go the Django route, Graham Dumpleton and the modwsgi Google group were very helpful to me. I could
not have gotten mod_wsgi deployed on Red Hat Enterprise 5 64-bit without Graham's help.
Whether you choose Django or "straight" Python, you will need to become familiar with mod_wsgi.
Good luck in quantum time, which means by now, I hope this all worked out for you.