Thursday, December 31, 2009

Re: questions from a noob - win7 using django

On Thu, Dec 31, 2009 at 5:31 AM, shofty <matt@bytejunkie.co.uk> wrote:
> ive been using django for a couple of weeks, i can see massive
> potential for actually finishing a couple of projects that i've had on
> the go for a good while. thing is its my first attempt at using a
> framework and ive found the tutorial followable, but lacking. it tells
> you what to do, but doesnt explain the why very well imo? so i've come
> to a point where i need a little assistance to take this further. i've
> got a couple of understanding points that once i get past im sure the
> frustration will die. I've actually written an app already, got quite
> far in it but in trying not to reinvent the wheel I've decided to use
> avatar and come up against a brick wall.

It's fine to ask for help. It's not necessary (and is probably inadvisable)
to justify your request by maligning documentation that many of us would
find tedious if it were any more detailed. I don't, for example, believe that
the django tutorial should be responsible for teaching one python. There
are fine tutorials for that at python.org and elsewhere on the net.


>
> so i've been through the tutorials. im struggling understanding how
> best to code for this on windows. im trying to make life as easy as
> possible for myself. ive seen pretty much no clues on how best to work
> in windows.

By installing the free VMWare stuff and a Linux distribution under it. You
did ask "how best", which is a request for an opinion, and that is my opinion.

But, actually, python and django work pretty well on windows. though I
can't say I've tried it on windows 7.

> i've got python installed at c:\python26 . im creating mysites at c:
> \django-sites
> - would experienced coders advise against this? would it be better to
> drop the django projects/apps inside the python path?

You can do either. When I've developed on windows I've put my
projects in home directory or even in (subdirectories of) the desktop.
It is probably wise to run the manage.py commands from a cmd.exe
session cd'ed to the directory containing manage.py and settings.py,
and I think that you can specify the current directory to use in a shortcut.
But you can actually put your projects in any directory you can access,
so \django-sites is fine. I wouldn't add that to the global python paht
environment variable, however.

>
> - im really struggling with apps. i've downloaded a few and tried to
> get them working by dropping them inside my project folder and linking
> them in. so for example i've tried to get brookie working by dropping
> it into c:\django-sites\projectname\django-brookie. all sorts of
> errors ensued.
> where would experienced coders put their apps? and then how do you
> link them into your project? i tried project.app inside the installed
> apps section, but it fails to pick up the urls file.
> is it best practice to use the setup.py file and then refer to it as
> django.contrib.brookie?

Where to put an app depends on what you're going to do with it. If I
expect to use the same unmodified version of the same app in many
projects, I definitely install it in the main python site-packages (often
by using easy_install). But if I want different versions in different
projects, say to track what's actually deployed on various production
servers, I may put it in the project directory (though I'm starting to use
virtualenv more and more, and you should check whether it works on
windows and use it if so). If I'm going to modify an app, I definately
put it under my project.

Note, however, that some apps expect to be installed globally, and the
way that they refer to parts of themselves can become invalid when
installed another way, requiring modification. For example:

import foo.views

might have to become:

import myproject.foo.views

or:

import myproject.apps.foo.views

For simply structured apps

import views

would have worked in all cases, but sometimes apps refer to one another,
and that never works, or some people want to put their views or modes in
a subfolder, meaning that they either need to restrict themselves to new
enough pythons that they can say:

from __future__ import absolute_imports

(or however it is spelled) or the app needs to be edited if plugged into an
unexpected spot in the module hierarchy.


Also, note that django NEVER picks up the urls.py of an app on it's own.
Your root urls.py must import it by whatever name necessary (probably
as the argument to an "include" in a urlpattern). django finds the models
module of the things in INSTALLED_APPS, but not urls. How would it know
where you want it plugged into your url scheme?

>
> any help is appreciated, i can tell django is something that i need to
> be using, but i just need to get past these first few hurdles. im
> going to invest in the books to see if a bit of light reading helps,
> but im impatient and frustrated!

You can't write python without writing python. If you haven't already done
so, find the tutorial on python.org and do it with patience and interest (might
take you a couple of hours), and then read all the python documentation you
can find about importing. That will actually take less time than stumbling
around in the dark.

Bill

--

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate