in django do we need to edit the model.py to fetch the data from database and show it in html - django

I am working on a blog application and i am trying to modify my Sqlite table through the DB browser for Sqlite
I have modified my table and created column in my sqlite3 database through DB browser for SQLite and now when i am trying to fetch the data in my django app it's not showing.
My exact problem is how do i get the data of column which i modified in the database Through the db browser.
When i try it with that in py shell i can see the data in my column. When i'm trying to add the column name in models.py it says duplicate column.

Related

I want to create tables in Django database by which may have dynamic fields by uploading a excel or csv sheet from a web interface

How can we create a DB table in db using django framework by
uploading a unique CSV/excel files
In front end there will be an upload button for uploading a CSV/excel and once user clicks​ submit a table should be created based on the fields in file uploaded
Help me on django dynamic models (if it can be implemented)
note: the columns may contain fields of different datatype like int,CharField
You can use Django import-export feature, or ImportExportModelAdmin.

How to Map table views of a legacy Database in Oracle to django models?

I am working on a project that requires connecting to an existing remote Oracle database. the problem is that the client has not given full access to the database. instead i'm only given accesss to some views(Relational Database View) of the database. the table names are not provided.
I'm able to perfrom raw sql queries to the legacydb in my django view.
But it would be very much more easier if i could generate the models for these views and use django ORM. is there any way to accomplish this? What I'm expecting is to use some commands like inspectdb to generate the models from the view provided by the oracle legacy database.

Can't add new rows to Postgres database at Heroku via Django admin

After provisioning my Postgres database on Heroku, I restored the structure and data from a local backup created using pg_dump.
I am unable to add new data to any table via Django admin. I get:
null value in column "id" violates not-null constraint
when adding data for any model. What's going on with this database?

Django create a Datatable using MSSQL

Hello I am new to using Django and would like to create a datatable with data that is stored in a database of an MSSQL server. I have managed to connect Django via django_mssql but I do not know how to access a table since there are many in the database. Thanks for your help.
first configure your db in Django setting and then read this docfile https://docs.djangoproject.com/en/1.11/howto/legacy-databases/

how to sync django models with pre-existing database?

I am having a hard time trying to come up with a reasonable design for my project. I have an existing Postgres database that gets constantly updated from other Python scripts.
The web server built on Django framework will access the Postgres database to update User models only and display blog information for the logged in Users. The blog information is what is being updated overnight by other Python scripts.
Now my question, if I have to syncdb my blog model with existing Postgres database, would that cause any problem?
ex:
models.py
class Blog:
title=...
content=...
author=....
And say my Postgres db called mydb has many tables, one of which is blog table and contains columns for title, content and author.
How would make my model in sync with existing database?
Now lets say I included a new column in my db which is date of entry.
If I simply update my model to :
class Blog:
title=...
content=...
author=....
date of entry=...
will it work.
what are the potential problems here and any simpler solutions for these?
P.S: I have used South in the past. but the situation here is different. I am using db that is read-only from Django's point of view, and no data migration is necessary as of now.
If your database is read-only, you don't have to do syncdb. Use managed=False and the db_table meta option on your model to specify the table name it corresponds to, and likewise for the field column names.
If you haven't already, see the doc on legacy databases for more info.