As the title states, I am curious what I need to know to make a website with Django.
My Attempts:
I am familiar with Python, but despite my attempts to begin work on a webpage(attempted some Django tutorials online and purchased "2 Scoops of Django" and started to work with some of its recommendations) I always feel like it points me at something else to learn. (PostgreSQL, git, virtualenv, VirtualBox, Vagrant, and more.) I understand that some of these are tools I just need to implement, but I feel as if I could delve into these much further and don't understand when I should stop trying to learn more about these.
My Goal:
I want to be able to develop a webpage with Django, and understand the steps and tools I am implementing.
My Question:
What tools do I need to learn, and how much about them do I need to learn to be able to begin working effectively with Django?
This is a very broad question but I can try to answer it as clearly as possible.
You said you are familiar with Python, that's a good thing. The next thing you should know is the MVC framework that Django is based on and uses extensively.
You can refer to Django tutorial here: https://docs.djangoproject.com/en/1.9/intro/tutorial01/ (as already mentioned)
I can give you a TLDR of how this can work:
1. Create a django project : $ django-admin startproject mysite
2. In the file structure that is created, the most important things would be:
a. models.py - your database models or schema defined as classes and objects
b. views.py - the view you are trying to display (mainly rendering .html in your case)
c. settings.py - you path, app setting, permissions, etc
d. urls.py - how you will be calling your specific views (redirect urls)
Once you write a basic app, try to run it using $python manage.py runserver and voila!
For the website part, there a few easy ways. You can download twitter bootstrap and try to attempt a simple page that you can find online with django http://getbootstrap.com/2.3.2/
As far as technologies go:
venv: is so that you do not mess up your other python, etc versions on your laptop, it isn't necessary
git: this is something you should learn irrespective of a project requirement. There are basic 3 commands that will be enough.
You might have to learn basics of HTML and CSS for manipulating your own website. Most of the backend can be handled on Django using objects of models you created.
Try these things out and let me know if you need anymore information.
Related
I want to change my static website (http://ingledow.co.uk) to a Django site on Heroku and Amazon using GitHub to store the code.
I've been through the Django tutorial once, so I'm fairly new to the whole thing.
Where would you guys start with this? Any useful books, code learning websites you could recommend to get started?
Thanks
David
To easily understand and visualize Heroku when hosting Django apps I created this drawing for our startup ChattyHive. I hope it is helpful. Don't hesitate on asking me any doubt or suggest anything :)
(please right clic on it and "view picture" to see it full size or it will be too small!)
The best way to learn Python and Django is to be comfortable with creating a proper environment for developing your application, although you can skip the details and start with Heroku's official guide on how to manage a Django application across the whole stack.
At the time of writing, these are some of the essential tools Python developers should be comfortable with:
virtualenv for creating distinct copies of the Python interpreter and it's environment
pip for managing Python dependencies
fabric for defining administrative tasks across all your target environments
puppet or chef for provisioning environments
vagrant for provisioning development environments
I would suggest that you immediately familiarize yourself with vagrant and focus on the virtualenv+pip+fabric trio--these are ubiquitously utilized in any Python web project and your bound to be forced to come to terms with them sooner or later, so get straight to it and you'll be otherwise amazed how you ever managed any Python development without them.
As far as learning Django is concerned, you will need to understand that Django is still just plain-old Python, what WSGI applications are, how domain objects are modeled, how Django routes requests, how views handle requests and how they produce responses, including additional and intermediary framework components. Afterwards, you should be knowledgeable enough to start tackling any requirements you might have of your application.
I will stress that having a good grasp on Python goes a long way in helping you understand how Django was designed and how to better write and organize your application's sources. The documentation is pretty exhaustive and it's the primary resource for any developer, but if you find yourself in need, there are several good books written that focus on providing additional material on certain aspects, but never forget to hone your Python skills.
Worth mentioning is the Django Package index which tracks any Python package specifically written to be integrated with Django. Their repositories are publicly accessible either on Github or Bitbucket and they range from tiny to huge and are an invaluable resource to see how other developers are doing Django development right.
Maybe you should start with some introduction books about Django,like The Django Book.
sorry I'm a total noob but I can't find anywhere that actually explains this. I want to make a web blog, and I figured instead of rolling my own I would use a pre-made one, and I picked the blog from the basic apps project (https://github.com/nathanborror/django-basic-apps). I installed everything fine, added the apps to my settings file, synced the DB's, etc. But now I don't know what to do. How to I actually use the blog? When I run the test server it says I have to do manage.py startapp but I already have the app folder. What should I do? Again, sorry for the noob question.
Best,
Jake
Rule of thumb is: if app's documentary doesn't explain how to install (use, etc.) app, then its better to forget about using that app.
How can you rely on 5-month-not-updated-not-tested-not-well-documented app? There should be better solution.
I am about to set up a project, and am wondering what the best way to do it is.
I notice some open source files have an "apps" directory, which stores all third-party apps, etc.
I was looking at the following two projects
https://github.com/josephmisiti/NewsBlur
https://github.com/dkukral/everyblock
My project will consist of code that will run multiple different (and connected) web applications.
I also found this:
https://github.com/lincolnloop/django-startproject/tree/master/django_startproject/project_template/myproject/
Thanks,
This question has been covered several times. See:
Django tips: laying out an application
Web Application (Django) typical project folder structure
Best practice folder hierarchy of a Django Web App
I don't think there is an exact 'best way' which is suitable for every project. But there are some general rules that may help you setup your project. I won't send any link about this but there are several documents and webpages, so keep Googling. It's the best way to learn some extra tricks while digging pages for a purpose.
Also, try to understand projects that is similar to the one you want to develop. You say you've been already doing it, I think it is going to be the most helpful thing you do for your project.
I just started working at a place as a front end developer where I need to build Django templates. I never worked with these before, does anyone know where I can download a sample template so I can look through the code structure?
I won't be doing any application development using the Django framework, only taking the variables the developer gives me and incorporating the in the html/css templates I build.
There are lots of Open Source django apps that you could look at for inspiration. One example is Zinnia which is a blogging application - there are dozens of templates in this project, see this directory. There are many other open source django projects on http://github.com and http://bitbucket.org
You should also take a look at the official template documentation, there are lots of snippets there that are very useful.
Here's a nice little tutorial.
http://www.webmonkey.com/2010/02/use_templates_in_django/
Also, Check out the Django Docs.
http://docs.djangoproject.com/en/1.3/ref/templates/builtins/
I need to write a basic website on Dreamhost. It needs to be done in Python.
I discovered Dreamhost permits me to write .py files, and read them.
Example:
#!/usr/bin/python
print "Content-type: text/html\n\n"
print "hello world"
So now I am looking for a basic framework, or a set of files that has already programmed the whole registration to be able to kick-off the project in a simple way.
By registration I mean the files to register a new account, log in, check the email (sending a mail), and edit the user information. All this possibly using MySQL.
Let me share my own experience with django. My prerequisits:
average knowledge of python
very weak idea of how web works (no js skills, just a bit of css)
my day job is filled with coding in C and I just wanted to try something different,
so there certainly was a passion to learn (I think this is the most important one)
Why I've chosen django:
I've already knew bits and pieces of python
django has excelent documentation, including tutorial, which explained everything
in very clear and simple manner
It is worth to read complete manual first (it took me two or three weekends. I remember I could not remember/understand everything at first pass, but it helped me to learn where
the information can be found when needed. There is also another source of documentaion
called djangobook. Djangobook contains same information as manual, but things are explained more in detail. It's worth to read it also, it helps to catch up with MVC concept, if you have not tried that before.
And finally to answer your question best: there are already also OpenId modules ready for you. I'm considering to use django-authopenid for my new project. It supports OpenId, while providing fallback to locally managed users.
There is certain learning curve if you are going learn django. The more you know about the web and python the steeper the curve is. I had to also learn bits and pieces of javascript and it took me also some time. If you are able to spend full time learning django, then
you can expect you'll be able to deliver first results within 4-6 weeks. It took me 6 months, since I was doing my django studies in free time.
There are several blog entries &c pointing out some problems with Python on Dreamhost and how to work around them to run several web frameworks that could suit you. (Most of the posts are over a year old so it may be that dreamhost has fixed some of the issues since then, of course, but the only way to really find out is to try!-).
Start with this page, dreamhost's own wikipage about Python -- at least you know it's quite current (was last updated earlier today!-). It gives instructions on using virtual env, building a custom Python &c if you absolutely need that, and running WSGI apps -- WSGI is the common underpinning of all modern Python web frameworks, including Django which everybody's recommending but also Pylons &c.
Some notes on running Pylons on Dreamhost are here (but it does look like Dreamhost has since fixed some issues, e.g. flup is now the dreamhost-recommended FCGI layer for WSGI as you'll see at the previously mentioned URL) and links therefrom. If you do go with Pylons, here is the best place to start considering how best to do auth (authentication and authorization) with it. I'm trying to play devil's advocate since everybody else's recommending django, but for a beginner django may in fact be better than pylons (still, spending a day or so lightly researching each main alternative, before you commit to one, is a good investment of your time!-).
For Django, again there's an official dreamhost wiki page and it's pretty thorough -- be sure to read through it and briefly to the other URLs it points to. The contributed auth module is no doubt the best way to do authentication and authorization if you do decide to go with Django.
And, whichever way you do choose -- best of luck!
django framework
You can try starting with django-registration.
EDIT: You can probably hack something up on your own faster than learning Django. However, learning a framework will serve you better. You'll be able to easily ask a large community when you have problems, and build on work that's already been done. And of course, if you're doing something new in the future, your knowledge of the framework can be more easily reapplied.
Django is the way to go. You can try it locally on your PC and see do you like it. It is very nice framework and allows you to quickly build your applications.
If you want to give Django quick go to see how it feels you can download Portable Python where everything is preinstalled and ready to use.
You can also do what you are trying to do with apache module mod_python (which is also used to run Django) but it would require more coding. Your code snippet would work with mod_python (http://www.modpython.org/) right away. I think mod_python comes pre-installed on Dreamhost so you can try it.
For a more complete basic setup (with lots of preprogrammed features) I would point you at Pinax which is a web site on top of Django (which I praise of course, see the dedicated page on dreamhost Wiki at http://wiki.dreamhost.com/Django)
The introduction on the project's web site (pinaxproject.com) :
Pinax is an open-source platform built on the Django Web Framework.
By integrating numerous reusable
Django apps to take care of the things
that many sites have in common, it
lets you focus on what makes your site
different.
There you will have a complete web site to customize and add features to.
I've noticed that a lot of people recommend Django. If you're running on a shared host on Dreamhost, the performance will not be satisfactory.
This is a known issue with Dreamhost shared hosting. I have installed web2py on my Dreamhost shared account and it seems to work okay; search the google groups for an install FAQ.
Later edit: google Dreamhost Django performance for an idea of what I mean.
Another voice to the choir.
Go for django. It's very good and easy to use.