goldy736 0 Newbie Poster

hi ,
i just started working in python , am using postgresql connected using turbo gears , python .
I have connected to DB modifying the dev.py ,
I want to display a created table from postgre sql in web browser using python turbo gears ,
my table in the DB is product_category
i have created product_category.kid with following code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:py="http://purl.org/kid/ns#"
    py:extends="master.kid">

<head>
    <title>Product Category: ${product_category.name}</title>
</head>

<body>
	<table id="product-info">
  <tr>
    <td class="fld">Name:</td>
    <td class="val"><span py:replace="product_category.name" /></td>
  </tr>
  <tr>
    <td class="fld">ID</td>
    <td class="val"><span py:replace="product_category.id" /></td>
  </tr>  
	</table>
</body>
</html>

And controllers.py is

import turbogears as tg
from turbogears import controllers, expose

class Root(controllers.Root):

    @expose("project2.templates.product_category")
    def index(self):
		from model import Product_Category
		product_category = Product_Category.selectBy(parent=None)[0]
		return dict(product_category=product_category)
		
    @expose("project2.templates.product_category")
    def product_category(self, product_categoryID):
		from model import Product_Category
		product_category = Product_Category.get(product_categoryID)
		return dict(product_category=product_category)

with model.py as follows,

import pkg_resources
pkg_resources.require("SQLObject>=0.10.1")
from turbogears.database import PackageHub
# import some basic SQLObject classes for declaring the data model
# (see http://www.sqlobject.org/SQLObject.html#declaring-the-class)
from sqlobject import SQLObject, SQLObjectNotFound, RelatedJoin
# import some datatypes for table columns from SQLObject
# (see http://www.sqlobject.org/SQLObject.html#column-types for more)
from sqlobject import StringCol, UnicodeCol, IntCol, DateTimeCol
from sqlobject import ForeignKey, UnicodeCol, IntCol, DateTimeCol
from sqlobject import MultipleJoin, UnicodeCol, IntCol, DateTimeCol
from sqlobject import CurrencyCol, UnicodeCol, IntCol, DateTimeCol

__connection__ = hub = PackageHub('project2')


class Product_Category(SQLObject):
	name = StringCol(length=64)
	parent_id = IntCol(default=None)

when i run the code in cmd prompt tg-admin start-project.py

connecting to browser i have the following error :

ProgrammingError: relation "product__category" does not exist

its been a day am trying to sort out . please any one can guide me out .

Thank you !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.