On 11/11/2018 3:23 AM, ARAVIND BALAN wrote:
>
> I used the inspectdb command but it does not solve my problem I still
> cant view the contents in user defined tables in psql
>
Did the manage.py inspectdb command write models for each of the
non-Django tables in the database?
If not - you need to study the docs and get that working. Once it has
written models for you, you can include them in admin.py alongside your
other Django models, start up the dev server and look at them at
http://localhost:8000/admin. That will prove whether or not the
user-defined tables are visible via the Django ORM. I am confident it
will work.
Once you have that proof, you can more confidently debug your
Django-psql interface.
Actually, I don't have a copy of your original email so I might not
understand the relationship you want between psql and Django. But in any
case you should be quickly able to view those tables in the Django Admin.
Good luck
Mike
>
> On 10 Nov 2018 4:17 a.m., "Mike Dewhirst" <
mi...@dewhirst.com.au
> <mailto:
mi...@dewhirst.com.au>> wrote:
>
> On 9/11/2018 11:04 PM, ARAVIND BALAN wrote:
>> I linked psql with django and can access django defined tables but cant access the contents of tables which I defined shows relation does not exist error . But can see the name of the table in \l command all the schema is public
>>
> That's probably because Django needs to know about those tables
> ie., the ORM needs models representing them. There is a manage.py
> command 'inspectdb' which should create Django models of your
> non-Django defined tables.
>
> python manage.py help inspectdb
> usage: manage.py inspectdb [-h] [--version] [-v {0,1,2,3}]
> [--settings SETTINGS] [--pythonpath
> PYTHONPATH]
> [--traceback] [--no-color] [--database
> DATABASE]
> [table [table ...]]
>
> Introspects the database tables in the given database and outputs
> a Django
> model module.
>
> positional arguments:
> table Selects what tables or views should be
> introspected.
>
> optional arguments:
> -h, --help show this help message and exit
> --version show program's version number and exit
> -v {0,1,2,3}, --verbosity {0,1,2,3}
> Verbosity level; 0=minimal output,
> 1=normal output,
> 2=verbose output, 3=very verbose output
> --settings SETTINGS The Python path to a settings module, e.g.
> "myproject.settings.main". If this isn't
> provided, the
> DJANGO_SETTINGS_MODULE environment
> variable will be
> used.
> --pythonpath PYTHONPATH
> A directory to add to the Python path, e.g.
> "/home/djangoprojects/myproject".
> --traceback Raise on CommandError exceptions
> --no-color Don't colorize the command output.
> --database DATABASE Nominates a database to introspect.
> Defaults to using
> the "default" database.
>