Friday, May 17, 2013

Re: new to Django and building web applications. Advice with postgresql

In addition to installing PostgreSQL you must use tools that come with the postgres installation to 1. create a database (a postgres installation has more than one), 2 create a user (unrelated to user account on the operating system) for django to use (though some people cheat and use the pre-defined "postgres" user), 3 set its password, and 4. grant it at least table creation permissions on the database you created.  If you want to connect to the database from other than the local machine, you will need to play with a configuration file (hba_conf, if memory serves).  pgadmin3, by the way, is a very useful tool that requires separate installation.  There are postgres tutorials on the web, and the postgres on line documentation is very good.  I think that there is at least one page in the django documents that details one sequence of commands for setting up an installed postgres for django.

 You will also need the python package psycopg2, elect to use it in settings.py, and, also in settings.py, specify your database, database user, and password.

But you don't have to do that all at once.  Learning about django with sqlite (included in modern pythons) won't leave you surprised when you start using postgres.  (Though if you start to put significant, that is, not just for test, content in your site it is time to move, since transferring content between them is not trivial.  It's a useful skill, but you will have enough on your plate.)

It seems that some people successfully develop django sites without a significant understanding of python.  But I would advise learning python as well and as soon as you can.  It will be valuable to you even if you stop using django.  (My current job has me working with tornado and the Apache Qpid implementation of AMQP, but I still do mostly python.)  You may already be aware of these, but I'd like to offer two starter tips for those coming to python from other languages:

  1. In most languages, including C++, a variable is a named piece of storage.  When you assign to it, the value is copied into that storage.  The storage has to be the right size to hold whatever you are storing (so the variable must be declared with a type).  The declaration also tells the compiler how to interpret the collection of bits in that storage.  In python, those things that look like variables all hold only (extended types of) references.  The "objects" referred to all have self evident types (that is, if you have one, you can tell what type it is), which is why declarations are unnecessary, and a "variable" can hold any type.  Assignment copies only the reference.

 2. To edit python use an editor that is aware of, or has been configured for, python.  No end of frustration results from editors using the ASCII tab character (as distinct from the Tab key on the keyboard) for indentation.  Since indentation is significant in python, it is vital that the indentation looks the same to you (and others) exactly how python will interpret it.  While python can deal with tab characters, and can even be told to interpret them as other than moving to the next multiple of 8 columns, someone else's editor, or printer output, etc., may display them differently.  So it is safest if your editor interprets the Tab key as meaning that it should insert the correct number of spaces.  Any IDE claiming to support python should do this.  Many python installations come with IDLE, or it can be added, and its editor gets this right.  vi or vim can be configure this way.  Modern emacs (my choice) versions come with a python mode, and it can be added to older ones.  Editors that don't think of themselves as being for programmers (notepad, wordpad, etc.) are not likely to even be able to be configured to do this right (fortunately many of the previously mentioned winners are free open source tools).


On Fri, May 17, 2013 at 1:16 AM, <d.gursha@gmail.com> wrote:
Hi, 

I'm new to building web applications, django, backend work, etc... I have experience in C++ up to A.P. computer science level if that means anything and I'm beginning to get a grasp on the python language. I've done all of the exercises on code academy and have watched fairly a lot of videos on building with django and python. I have somewhat of a grasp on the overall design of files in the terminal that are involved (url.py, views.py, etc...). I've been following http://www.djangobook.com/en/2.0/chapter02.html. My question is It was suggested by this free online open source book to install postgresql, so I did but I had no idea how to use it and kind of gave up on it and setting up the backend. Can anyone suggest a resource a book perhaps that can guide me in the right direction or just give some friendly advice. My goal by the end of the summer is to be able to build a substantial dynamic web application with python in Django that will have the feel of a Khan Academy or code academy (a dynamic website that is able to hold lots of content and have a user-interface with accounts, logins, rewards systems and much more) and be launced on the web for the world to see and use. The only other true experience I have with web design is with static web pages and basic HTML and CSS. Yes, it is a big goal, but I think I can do it with the right amount of guidance. I have all summer to learn. Hell, you have to start somewhere right? All suggestions are welcome.

Thanks.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate