import

31 views
Skip to first unread message

Johan Hendriks

unread,
Feb 11, 2014, 5:26:19 AM2/11/14
to django...@googlegroups.com
Hello all.

I have a little question, maybe a little stupid but non the less it
keeps me busy. :-)

I want to start making some web based apps as a hobby project.
I have no coding experience other then some basic shell scripting to get
some daily routine jobs done on my FreeBSD servers.
The first struggle I had to take is the programming language, I looked
at PHP and python, and I think my best option is Python, and with python
comes Django.
So the last weeks i have been doing some searches on google and view a
lot of tutorial video's how to start with django.

One thing that always comes back is the import part like below

from django.http import HttpResponse

And here comes my question, where and how do you know what you need to
import.
What is the best way to learn al these imports? , and is there a quick
way to find the imports you need?

Thank you for your time.

regards
Johan



Adolphe Cher-Aime

unread,
Feb 11, 2014, 8:00:28 AM2/11/14
to django...@googlegroups.com
Hi Hendriks,

My suggestion to you is to first take a look at the python language it self as  Django is as python framework. There's a lot of tutorials out there to help you. When you feel that you understand python, you can come back to django.
The good news is you don't have to be a Python expert to build good web apps in Django.


Good luck.

Adolphe Cher-Aime




Johan



--
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...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/52F9FACB.5010108%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.




Timothy W. Cook

unread,
Feb 11, 2014, 8:01:09 AM2/11/14
to django...@googlegroups.com
Welcome to the wonderful world of Python.  I suggest that you immerse yourself in http://www.greenteapress.com/thinkpython/  and then take this (free) course next month https://www.coursera.org/course/interactivepython  before tackling anything like Django.  

Best,
Tim

 



Johan



--
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...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/52F9FACB.5010108%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
MLHIM VIP Signup: http://goo.gl/22B0U
============================================
Timothy Cook, MSc           +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

Vineet Naik

unread,
Feb 11, 2014, 8:37:36 AM2/11/14
to django...@googlegroups.com
+1 for getting yourself familiar with Python first before trying to learn a framework like django. 

Since you mentioned that you have no significant programming experience, I would like to suggest  
"Learn Python the hard way" which is free to read online (http://learnpythonthehardway.org/book/)

Regards,
Vineet


To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

For more options, visit https://groups.google.com/groups/opt_out.



--
~ Vineet

Manu

unread,
Feb 11, 2014, 8:44:17 AM2/11/14
to django...@googlegroups.com
Hi Johan,

I don't know if you put sometime into learning python. These imports are a way to reuse other modules that already provide some of the functionality that you are trying to achieve. To know the right module to import from and to select the right things to import, you should consult that package's documentation. Like django documentation for imports from django.

All the best!
- Manu,

Johan Beyers

unread,
Feb 11, 2014, 8:33:32 AM2/11/14
to django...@googlegroups.com
Hi, Johan,

To answer the spirit of your question: Mostly, you will get the correct import locations from the examples you use. Once you're used to Python, you will see that there is a logic to the imports:

* You start at wherever your virtualenv stores its site-packages if you use virtualenv, otherwise it should be somewhere in your Python path. For example, my virtualenv directory is called ve, so I start at ve/lib/python2.7/site-packages.

* Next you just burrow down the path, keeping in mind the convention that a python module that you can import from is either a file with the module name, or a directory with the module name, that has an __init__.py file in it. For example: The import source above could be in ve/lib/python2.7/site-packages/django/http.py or in  ve/lib/python2.7/site-packages/django/http/__init__.py. In our case, the second one is the right one.

* Note that when you open up that file, you see that it actually imports the HttpResponse from django.http.response, which sits in the same directory in the response.py file. This is usually due to a few factors: Backwards compatibility, more compact imports of related functionality from elsewhere, or maybe it's just the preferred coding style :)

OK, so that covers django imports, as well as other specific packages in your requirements files, if you use pip (and you should, really). There are 2 other non-obvious places you will have imports:

1. If you have installed extra python packages globally, you might be able to import those from other locations in the path. There, you probably need to open a python debugger and look at sys.path to see where to start looking for the actual files.

2. Python has many, many modules included, but not imported by default. These you will encounter as you search for examples on how to do things in Python. For example, math:

>>> from math import sqrt
>>> sqrt(16)
4

That should cover it. Keep in mind that Python is open source, so you can find most of this from reading the source code. However, it's all documented pretty well on the Django site, as well as various Python docs sites.

Hope this helps,

Johan

Johan Hendriks

unread,
Feb 11, 2014, 10:24:23 AM2/11/14
to django...@googlegroups.com
Johan Hendriks schreef:
Thank you all for the comments.
I will start with the options given like think python and learn python
the hard way, then try to convert my bash scripts into python scripts.

In the mean time i will lurk this mailing list....

regards
Johan


Reply all
Reply to author
Forward
0 new messages