Planet dgplug

September 02, 2010

Kenneth Gonsalves

django-addition

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.

September 02, 2010 12:12 PM

August 31, 2010

Kenneth Gonsalves

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)
    else:
        form = Addnumform()
    return render_to_response('web/addnum.html',
                        context_instance=RequestContext(request,
    
                              {"form":form,
                               
                               }))

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

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

url(r'getnum/$','project.addnums.views.getnum',name='getnum'),
url(r'success/(?P\d+)/$','project.addnums.views.success,name='success'),

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 %}
{{nums}}
{% 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 http://127.0.0.1:8000 and start learning arithmetic.

August 31, 2010 09:34 AM

August 30, 2010

Bamacharan Kundu

Screenshot-7

I have Changed the login screen previously it was taking input User name, password, Base URL and topic or product as

Now at first User has to give the base URL which can be selected from one drop down box, and User name and password. like

After clicking login it will login to the base URL and if success full then it will go to the product selection page.

Then clicking the finish button it will load the bugs for first run depending on the selected product and continue with a screen

Once the bugs are loaded then and next run onwords it will go to the main window which will show the list of bugs already downloaded.

I have added the modify option to it if one bug is selected from the list of the bugs it can be modified with their fields and comments can be added.

Thaks.:)


by Bamacharan Kundu at August 30, 2010 01:50 AM

August 29, 2010

Ratnadeep Debnath

rtnpro

Lately, I worked on fine tuning the code for wordgroupz. I fixed some bugs that I was aware of, like unable to parse data retrieved from wiktionary pages which did not have any ‘Contents’ field, error launching games when no words in db, some bugs in webster view, etc. Now, I have added a dialog which will show a message saying ‘Not enough data’ if the number of words in the db are not enough for playing games. I have also added support for parsing data from wiktionary pages which have no ‘Contents’ field. Also made some fixes in the webster view.

I today updated the RPM for wordgroupz to wordgroupz-0.3b-4.fc13.noarch.rpm

You can install the latest version of wordgroupz as follows:

1) download rtnpro.repo into /etc/yum.repos.d/

2) then as root, do :

yum install wordgroupz

You can also get the source code from http://gitorious.org/wordgroupz/

Please test wordgroupz, and feel free to drop in your suggestions.


by rtnpro at August 29, 2010 10:58 AM