Django real world website samples (with django source codes)

2011-04-06 Thread django beginner
Hi all,

Could someone please give a link on some of the samples for real world
Django websites?
Thanks and have a nice day!

Regards,
Django Beginner

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to create message box window using Django

2011-03-29 Thread django beginner
Hi all,

Could someone please tell me how to create a Message Box using Django?

Thanks in advance.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



validate user input on templates

2011-03-27 Thread django beginner
Hi django experts,

just want to know your opinion on how to validate the user input
(example: the user input field should be integer, but the user
accidentally inputs any character), here is my code:

FYI; the numberofapples field is IntegerField

here is my sample code:

def apples_edit(request):
if request.POST['id']:
 id = request.POST['id']
 numberofapples = request.POST['numberofapples']
 conn = psycopg2.connect("dbname=my_db user=user password=pass
host=localhost")
 cur = conn.cursor()

try:
   if isDigit(playerid):
pass
   else:
template_name = 'err_template.html'
t = loader.get_template(template_name)
c = RequestContext(request, {"err_msg":"number of
apples should be integer, Please correct your input"})
return HttpResponse(t.render(c))
except ValueError:
template_name = 'err_template.html'
t = loader.get_template(template_name)
c = RequestContext(request, {"err_msg":"number of apples
should be integer, Please correct your input"})
return HttpResponse(t.render(c))

 sql = """ UPDATE my_db SET "numberofapples"='%s' where "id"='%s'
""" % (numberofapples,id)
 cur.execute(sql)
 conn.commit()
 conn.close()

--
My problem is that, the error template does not appear after I type in
any character for numberofapples field.
What would be the correct code for this?

Thanks.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



how to parse string in django

2011-03-27 Thread django beginner
hi django experts,

how do I strip the following string in python (Charfield format)

14:00
3:00

wherein I could compare the results - convert in integer:

if 14 > 3 . . .

thanks in advance!

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



how to parse string in django

2011-03-27 Thread django beginner
hi django experts,

how do I strip the following string in python (Charfield format)

14:00
3:00

wherein I could compare the results - convert in integer:

if 14 > 3 . . .

thanks in advance!

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



how to parse string in django

2011-03-27 Thread django beginner
hi django experts,

how do I strip the following string in python (Charfield format)

14:00
3:00

wherein I could compare the results - convert in integer:

if 14 > 3 . . .

thanks in advance!

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



case sensitive model fields: does object_id gets smallcap field?

2011-03-20 Thread django beginner
Hi all,

Suppose I have these data:

class Name(models.Model):
nameId = models.AutoField(primary_key=True)
name = models.CharField(max_length=20)
nameAddress = models.CharField(max_length=50)

on my views.py:
def name_delete(request, object_id):
conn = psycopg2.connect("dbname=mydb user=postgres password=sa
host=localhost")
cur = conn.cursor()
sql = "delete from name where nameId = '%s'"% (object_id)
cur.execute(sql)
conn.commit()
conn.close()
return HttpResponseRedirect("/Mylist")

it seems that object_id got the nameid field instead of the nameId
camelcase column. is it true for all?
I got this everytime I try to delete a row on my list:

ProgrammingError at /deletename/

column "name_id" does not exist
LINE 1: ...DELETE from name ' WHERE name_Id='1'
-

Thanks!

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



how to compose templates with widgets (that has dynamic contents in it)

2011-03-20 Thread django beginner
hi django experts!

May I know how to create templates that has django widgets in it?
please refer to my should-be template output below:


Name:  


here is the sample model:

class Name(models.Model):
name_id = models.AutoField(primary_key=True)
name = models.CharField(max_length=50)

def __unicode__(self):
return self.name

Thanks in advance

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How do I use widgets on Templates and (not on Forms)?

2011-03-18 Thread django beginner
Hi all,

How do I use widgets on the field of a template(not forms)? Let's say
I have a field called Member, and this field should be in select form
that has choices from members table (field: member_name)?

tried using select option on html, but it ain't seem to work. any
inputs? Thanks.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Add, Edit and Delete link using Forms (not templates) per row without using built django-admin functionality

2011-03-17 Thread django beginner
Hi Django users,

I am having some dilemma over converting simple admin page Template
(without having to use the built in django-admin functionality) by
using forms, and not templates, I have the following sample Admin page
that allows users to add, edit and delete record per row to Forms:
(Edit and Delete will be links that will be directed to designated
forms)

table.html: (/timetable)

Booking ID   Golf Club   Status
1 Country Golf  PendingEdit  Delete
2 Pacific Harbour  Cancelled  Edit  Delete
3 Pacific DunesBooked Edit Delete
4 Peninsula  Booked Edit Delete
---
Model:
class Booking(models.Model):
bookingId = models.AutoField(primary_key=True)
golfClubName = models.CharField(max_length=50)
status = models.CharField(max_length=20)


views.py
def book_tee_delete(request, object_id):
conn = psycopg2.connect("dbname=my_db user=postgres password=sa
host=localhost")
cur = conn.cursor()
sql = "delete from booking where bookingId = '%s'"% (object_id)
cur.execute(sql)
conn.commit()
conn.close()
return HttpResponseRedirect("/timetable")

def edit_book_tee(request, object_id, model):
booking = Booking.objects.get(pk=int(object_id))
template_name = 'edit_form.html'
t = loader.get_template(template_name)
c = RequestContext(request, {"obj": booking, "id":object_id})
return HttpResponse(t.render(c))

def save_edit(request):
time_format = "%Y-%m-%d %H:%M"
if request.POST['submit'] == 'Save':
 bookingid = request.POST['id']
 golfclubname = request.POST['golfclubname1']
 status = request.POST['status1']
 conn = psycopg2.connect("dbname=my_db user=postgres
password=sa host=localhost")
 cur = conn.cursor()
 sql = "UPDATE booking SET golfClubName='%s', status='%s WHERE
bookingId='%s'" %(golfclubname,status,bookingid)
 cur.execute(sql)
 conn.commit()
 conn.close()
else:#for delete
bookingid = request.POST['id']
conn = psycopg2.connect("dbname=my_db user=postgres
password=sa host=localhost")
cur = conn.cursor()
sql = "delete from chasingbirdies_booking where bookingId =
'%s'" % (bookingid)
cur.execute(sql)
conn.commit()
conn.close()
return HttpResponseRedirect("/timetable")

table.html: (Template)
{% extends "base.html" %}
{% load i18n %}

{% block content %}



Booking ID
Golf Club
Status





{% if teetime_list%}

{% for res in teetime_list %}

{{ res.bookingId}}
{{ res.golfClubName }}
{{ res.status }}
Edit
Delete

{% endfor %}
{% else %}
No lists available.
{% endif %}


{% endblock %}

edit.html (Template)



{% if error_message %}{{ error_message }}{% endif %}
{% csrf_token %}



Edit Teetime



Booking ID

   

Golf Club



Status














---
My question would be, how do I transform templates on the Edit/Delete
link into Forms, (my other question would be, is there any way I could
show my css using templates on Edit?)?
Thanks in advance!





-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



how to search data from tables

2011-03-13 Thread django beginner
Hi all,

I would like to know is there any way I can search any data from
tables given some parameters:
Suppose I have this person model:

class Person(models.Model):
userid = models.AutoField(primary_key=True)
fname = models.CharField(max_length=30)
lname = models.CharField(max_length=30)
age = models.IntegerField(max_length=2)
nationality = models.CharField(max_length=50)
def __unicode__(self):
return self.fname

--
and, suppose I have these existing data from person_table:

userid  fname  lname age
nationality
1 Marie  Santos
21Canadian
2 AnnReyes
18Canadian
3 John   Smith
17American
4 Beth   Anderson
17American
5 LaniJackson
17   American

-
Now, I have these user input as search parameters:
Nationality:  American
Age: 17

---
The results should output these data:
userid  fname  lname age
nationality
3 John   Smith
17American
4 Beth   Anderson
17American
5 LaniJackson
17   American

---
Could someone please give me a sample code for this simple search
query using Django? Thank you so much.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.