On 2013-12-02, at 10:42 PM, Swastik Acharya <[email protected]> wrote:
> django 1.4 version
> postgresql 9.1 version
>
> I have successfully loaded all the html files and css on browser using django.
> Now i have some tables in postgresql ,which i need to integrate it with
> django and .html files so that data will be read and execute both from html
> file inputs and database table.
> what are the steps to achieve this ?
>
If you have a working Django installation, you just need your models.py to have
a definition matching your existing table(s) and you will probably want to have
an admin.py to give you easy first access to these tables.
> the home.html contains the macid,hostname,blacklisted etc whatever are there
> in postgresql table.
> i just need to connect and file up those blank spaces in html with data from
> postgresql table.
>
Have you worked through the Django tutorial?
You will need your home.html to retrieve your table items as context variables.
Having a views.py with a view inheriting from ListView will probably be helpful
here. Then your urls.py at the top level of your site needs to map the home
page pattern ("^$") to your view.
>
> for ex:
> my folder structure is
> >folder
> >mysite
> >app
> -static
> -style.css
> -main.css
> -templates
> -home.html
> -init.py and init.pyc
> -models.py and models.pyc
> -test.py
> -views.py
>
> >mysite
> -init.py
> -settings.py and settings.pyc
> -urls.py and urls.pyc
> -views.py and views.pyc
> -wsgi.py
> >mysite.db
> >manage.py
>
>
> and in postgresql the table name is device_table
> and its contents are:
>
>
> CREATE TABLE device_table
> (
> serial_no serial NOT NULL,
> macid character varying(100) NOT NULL,
> date_time_of_installation timestamp without time zone,
> blacklisted boolean,
> activated integer,
> deactivated boolean,
> reason character varying(500),
> hostname character varying(255),
> host_ip character varying(50),
> agent_version character varying(75),
> CONSTRAINT device_table_pkey PRIMARY KEY (macid)
> )
> WITH (
> OIDS=FALSE
> );
> ALTER TABLE device_table OWNER TO postgres;
>
> Note:I have created models.py by running inspectdb command.
Does your models.py have a Meta class with a line
db_table="device_table"
?
Please post your urls.py and models.py and also give details on what specific
problem you are seeing.
hth
- Tom
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/893C8680-F56E-4BA9-95F1-9DE83813EBCB%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.