Log in

No account? Create an account
how to set environmental variables in windows 7
[16:20] [djangoobie] anyone have tips on configuring DJANGO_SETTINGS_MODULE on windows 7
[16:21] [all_vs_one] whhat knd of tips do you need?
[16:22] [djangoobie] whenever I use manage.py syncdb or the reset function it can't continue because DJANGO_SETTINGS_MODULE is either undefined or incorrect
[16:22] --] innervision has joined this channel (~david@
[16:22] [djangoobie] i've added 2 system environment variables, PYTHONPATH and DJANGO_SETTINGS_MODULE
[16:23] [all_vs_one] have't you forgot to add database configuration in settings.py?
[16:23] [FunkyBob] djangoobie: honestly, from what I've seen of all the pain in here from people using windows.... you will generally be better off running a vm of linux/freebsd/something-unixy
[16:24] [FunkyBob] even given the learning curve if you've never used *nix before... it will be easier
[16:24] [FunkyBob] that's, as I said, from my observations in this channel of the problems people have trying to work in Windows
[16:24] [djangoobie] I can't use linux and I don't have any experience with it
[16:24] --] cdr_ has joined this channel (~cdr@94-192-110-239.zone6.bethere.co.uk).
[16:24] [FunkyBob] [true, some people have it all sorted, and appear to work on Windows no problem]
[16:24] --] jorn has joined this channel (~jorn@unaffiliated/jorn).
[16:24] [FunkyBob] can't? why not?
[16:25] [all_vs_one] for enjoining good things you have to try bad things ath the beginning

[16:25] [FunkyBob] djangoobie: from memory... don't you have to log out and back in after setting env vars in Win32?
[16:25] [all_vs_one] djangoobie: take virtualbox, ubuntu and play

[16:25] [djangoobie] I'm doing graphic design between the development process and switching 2 OS all the time will drive me crazy
[16:25] [-- cyberdelia has left this server (Quit: Leaving...).
[16:25] [apollo13] s/tutorial/docs/
[16:26] [FunkyBob] djangoobie: that's why I suggested using a VM
[16:26] [djangoobie] I logged out

[16:26] [lawgon] FunkyBob: the other day I went to a browsing centre for a printout and the guy had to reboot after inserting the usb stick
[16:27] [lawgon] djangoobie: lot of people do graphic design on linux
[16:27] [FunkyBob] lawgon: "Windows has detected that you have moved your mouse. Your computer needs to reboot to handle these changes."

[16:27] [djangoobie] can the problem be PostgreSQL
[16:31] [djangoobie] so I set up the environment variables like in the docs, but now I get "Error: No module named settings"
[16:31] [FunkyBob] djangoobie: both SQLite and Postgres would require it to be set
[16:31] --] sym has joined this channel (~sym@cust27-dsl45.idnet.net).
[16:31] [FunkyBob] djangoobie: ah, well.. that's often caused by people misunderstanding PYTHONPAHT
[16:31] [-- sym has left this server (Client Quit).
[16:31] [lawgon] FunkyBob: is a that a thai dish?
[16:32] [djangoobie] :)
[16:32] --] r0bby_ has joined this channel (~wakawaka@guifications/user/r0bby).
[16:32] *** r0bby_ is now known as robbyoconnor.
[16:32] [FunkyBob] lawgon: :P
[16:32] [djangoobie] so how do I fix it?
[16:32] [FunkyBob] djangoobie: did you set/change PYTHONPATH env var?
[16:33] [-- beevee has left this server (Quit: Leaving.).
[16:33] [djangoobie] via Python you mean?
[16:33] [FunkyBob] no, the same way you set DJANGO_SETTINGS_MODULE
[16:33] --] keyo has joined this channel (7cbf53ee@gateway/web/freenode/ip.
[16:33] [djangoobie] yes it's configured one directory above my project
[16:34] [lawgon] configured where?
[16:35] [djangoobie] in the system environment variables window I added 2 variables, one called PYTHONPATH with the value of D:\djangoprojects and the django module variable is configured to be mysite.settings
[16:36] [apollo13] djangoobie: did you relogin?
[16:36] [m0no] djangoobie: well you dont need to add django settings module env variable in system environment
[16:36] [FunkyBob] apollo13: well, I think I've seen 3 or 4 people in the last month sk about it
[16:36] [djangoobie] yes I logged out for the changes to take efect
[16:36] [apollo13] try a reboot *runs*
[16:37] [m0no] djangoobie: presumably you have \djangoprojectz\mysite as your structure
[16:37] [apollo13] + check in the console if the env vars are configured correctly
[16:37] [djangoobie] m0no: yes
[16:38] [m0no] djangoobie: and djangoprojects\mysite has an __init__.py, settings.py, urls.py in it
[16:38] [djangoobie] yes
[16:38] [djangoobie] if I echo the PYTHONPATH in cmd it displays the correct path
[16:39] [FunkyBob] ok
[16:39] [FunkyBob] so, in a totally unrelated directory, run python
[16:39] [m0no] ok so open a new cmd window (as this will ahve latest env vars set)
[16:45] [djangoobie] brb gotta relogin
[16:45] [-- djangoobie has left this server.

[16:49] --] djangoobie has joined this channel (~djangoobi@82-169-114-214.ip.telfort.nl).
[16:49] [djangoobie] ok where were we :p, I had to import settings from django.conf ?
[16:52] [djangoobie] then what?
[16:55] [lawgon] reboot
[16:55] [djangoobie] the ENV variables are all loaded, no need to restart

[16:58] [djangoobie] i'll remove the DJANGO_SETTINGS_MODULE and see if it will work then, brb
[16:58] [-- djangoobie has left this server.

contributing to open source
Recently I have been embroiled in debates on several fora on what exactly is contributing to open source and how to go about it. And there guys who are going around rating contribution as 'good' contribution and 'not good' or 'second rate' contribution. In one case the advice runs like this: look around on sourceforge etc for projects you like and go ahead and contribute to them. I feel that all this comes from a fundamental lack of understanding of how open source works. In the closed source world there are two defined roles - creators and users. And a firm line between the roles. In open source, the difference between a contributor and a user is not clearly defined. Every user is in some way also a contributor.

ok, so I want to contribute - how do I do it? Why do you want to contribute? if you contribute for the sake of contributing or for the sake of giving something back to the community or because you feel you should - it is likely that your contribution will be worthless, it will irritate the developers in the project and will certainly not sustain.

From my experience and from observation, the first way to contribute to an app is by using it. You use it because you need it. Then you have problems, so you get on IRC or a mailing list and ask questions. Using is contributing. Asking questions is contributing as it shows that maybe documentation is not good or the layout of the UI is confusing. As you keep using the app, you start interacting with the community. And depending on your level, you may remain at the stage of just asking questions, or maybe suggesting features, or maybe contributing patches and code - or translating strings, improving the documents - and possibly, one fine day you are a full fledged core developer. Or may be not. You write tutorials and blog posts on the way you have solved some problem or the other - you do not need commit rights to do that. You may write plugins or develop ui schemes - you do not need commit rights for that either. Since you have become known in the community as a user, a participant in online fora and adding tutorials, howtos etc, you are not seen as an interloper or busybody - but rather as a member of the community.

Developers are absurdly grateful for this kind of contribution - be it just downloading and using the app (and hence contributing to user statistics), or whatever.

Other ways - joining a LUG, attending LUG meets, going around conducting or helping to conduct workshops, seminars, install fests. Installing foss labs in institutions. Installing linux anywhere. And talking about foss - it is talk that distinguishes us from monkeys. Yes, talk is contribution too.

And which is the best type of contribution? No genuine member of the FOSS community would even dream of asking this question.

frankly I am getting tired of fighting. Why do it? You do not get popular. People who you think are friends get bought off. You are villified for trying to enforce rules. Fortunately I am not standing for election in anything - so can go my own way. And I will cease fighting when they are lowering me into the grave - not before.

the conference that never was
so finally the opposition got together to organise a transparent, democratic, community conference to expose foss.in. Support snowballed - then came a lowlife called Kalia - took a prominent role in the fledgling conference without a name, and then one fine day he defected to the other side. Boom - no conference. Lessons learnt:

1. No edifice built on sand will stand long
2. Never trust a php guy.

new app
an app I wrote back in 2007 and been meaning to release since then. Finally got down to upgrading it - needs work as I have learnt a lot since 2007 and django also has developed a lot. I hope I can get time to work on it. http://quadmulc.greenchilly.in - comments, criticism and testing welcome.

nice to see that the foss community of Bangalore has finally woken up and developed a backbone. All the best for the upcoming conference - if it takes place I will be there. More at http://fsck.in

pycon India rocks again
well pycon india took place again. Audience up from 350 last year to 650 this year. Talks were better, organisation good, venue comfortable. We also had the first AGM of the Indian Python Software Society. It went well. It is a great achievement to carry on for 2 years in India without a single split, major fight or walk out. Probably because people are more dedicated to python than to their egos? Next year in Chennai. Let us see how that works out. So far many organisations have planned to hold their conferences in different cities every time - but it has never worked out since the organisers are usually so desperate to hold on to their positions as netas that they have never succeeded in letting the event out of their sights. Except for David Goodger's keynote and Noufal's talk on the road to pycon, I did not manage to catch a full session.

bsnl 3G on fedora - phew
got bsnl 3G and managed to get it to work on fedora 12. It comes with software for linux - presumably written in shell or C, but behaves as if it is written in php by a baaad coder. It does not work. To make a long story short, fedora recognises it as a mass storage device. Actually there seem to be three devices there. So one needs to jump through hoops and use usb_modeswitch to make it into a modem. And then use wvdial as usual. I am too exhausted to describe the process. Suffice to say I got it to work. Phew.

django-addition has moved here: http://bitbucket.org/lawgon/django-addition/wiki/Home. Reason for the move is that livejournal is not very amenable to posting code.

how to add two numbers in django
For people coming from backgrounds of php or of application servers, the process by which django works is slightly puzzling. Maybe a simple tutorial that does the barest minimum would put them on the right path - so here is a attempt to do this wrt a thread that came up on the django-users mailing list. Comments?

1. download django:
svn co http://code.djangoproject.com/svn/django/trunk/ django-trunk

2. symlink django to the site-packages directory
ln -s pathtodjango-trunk/django /usr/lib/python2.x/site-packages/django

3. set up django:
python pathtodjango-admin.py startproject project
cd project
python manage.py startapp addnums

4. edit settings.py to point to a database called addnums
4.5 add project.addnums to INSTALLED_APPS in settings.py

5. create the database addnums

6. create a model in models.py which will be in the addnums directory:
class Addnum(models.Model):
    num1 = models.IntegerField("First number")
    num2 = models.IntegerField("Second number")
    # display result:
    def __unicode__(self):
        return "%s plus %s is %s" %(self.num1,self.num2,selfnum1+self.num2)

6.5 create the database table

python manage.py syncdb

7. Create a form in views.py:
from django.template import Context,loader,RequestContext

from django.shortcuts import render_to_response, get_object_or_404
from django.forms import ModelForm
from project.addnums.models import Addnum

class Addnumform(forms.ModelForm):
    class Meta:
        model = Addnum

8. Create a view to display and get the data from the form
def getnum(request):
    if request.POST:
        form = Addnumform(request.POST)
        if form.is_valid:
            f = form.save()
            #return a success view with the result
            return HttpResponseRedirect("/success/%d/" % f.id)
        form = Addnumform()
    return render_to_response('web/addnum.html',

9. create the success view:
def success(request,id):
    nums = Addnum.objects.get(pk=id)
    return render_to_response('web/addnum.html',

10. create urls for django to find your views in urls.py:


11. create a base template called base.html:
{% block content%}{% endblock %}

12. create getnums.html:

{% extends base.html %}
{%block content %}

{% if form.errors %} Please correct the errors below {% endif %}

{% csrf_token %} {{ form }} {% endblock %}

13. create success.html:
{% extends base.html %}
{%block content %}
{% endblock %}

14. add the directory holding your templates to the templates directory in settings.py

15. run python manage.py runserver

16. point browser to and start learning arithmetic.