I'm using Django with sqlite to make a web app and ran into a little issue.
I created a table under models file called deletedOrder, gave it variables etc., and then ran manage.py syncdb. This created the table in my database and I was able to add data to the database table and read the data back out, however this added table is not showing up on the Django admin interface.
Is there something else that I have to do to get this to be in the admin page?
You need to register your models to make them show up in the admin as documented here.
Related
I have existing Laravel website up and running at https://iqtestsite.com/ . I want to install a blog section for this website using wordpress. When i try one click installation, it shows an error that database already exist.
My Domain can only have one database, i currently have important data on the server. I can't lose any part of the data.
How should i proceed here.
Thanks for reading.
This question is off-topic still I'll try to answer your question.
put the Wordpress Blog in the 'public' folder of your Laravel app.
i.e. .../laravel_app/public/wordpress_blog
or simply: laravel_app/public/blog
you can access the blog at https://www.your-site.com/blog
you can access the admin at https://www.your-site.com/blog/wp_admin
no need to worry about the routes in laravel, it will work just fine.
You can use the same database for both, just use a prefix for the WordPress tables e.g. 'wp_table_name'. you can set a prefix during WordPress installation. So you have a single database for both Laravel & Wordpress tables.
In WordPress table prefix write wp2_
rest all you can put as same as before...
I guess it will work...
the restriction is always on the database, not tables... so add tables same as woocoomerce / wordfence and other olugin insert own tables in your database... so you can incert your tables in old database
Within my Django app I currently only have one DB, under settings it is default. What I want to do is port over all of the Auth tables created by Django to a separate database, Ill say SiteAuth for now.
I have copied all of the auth tables over to the SiteAuth db, but I am not sure how to integrate those changes within the site. I know I am going to have to add another db the databases section of settings, But I am not sure how to do the migrations, or how to specify which database I want to query.
How would I do the migrations? how would I specify which database I want to query? how would my models.py change?
Thanks for all the help!
you need to write a router. Check this:
https://docs.djangoproject.com/en/2.2/topics/db/multi-db/
I would recommend to keep the auth in the default db, and move the other stuff in the new one. On the other questions the docs are very descriptive, but to summarize you need to add stuff to the Meta class of your models.
Our CakePHP 3 app (a POS System) is going to use subdomain approach where clients will share a common code base but run on individual databases.
2 things from the config (app.php) file will be unique to each instance : database details and security salt. These details will be stored in a table of main site database (wordpress) and I want to load them based on the subdomain opened. (abc.maindomain.com or xyz.maindomain.com)
I am not sure where should I implement this stuff in the code. bootstrap.php seems to be the only viable solution for now. What are experts' thoughts over this? I plan to store those details in a session once loaded so that system doesn't need to call main database everytime.
I want to connect Django to a database that the user will set in the main page.
The user will have to precise the engine (with a combobox), the database, login, password etc in a form, and I want to proceed the connection with the submit.
So far, I tried to set "DATABASES = {}" in settings.py, but it returns an error.
Have you got any clue about how to do it?
You have to connect your app to a database.
There is no way that I know of to change the database connection dynamically.
The only things I can think of are a bit convoluted:
If you want to change your back-end database:
I would suggest having a separate setting file for the database (I will call it dbsettings.py) that you will include in the settings file.
At the submit, you would lunch a script that will change the dbsettings.py file, and restart the django server (with a CLI call for example)
If the database is user specific, configure and fire up another django instance, and have the two instances communicate (you could use celery for messaging or django commands)
I (and other people) may come up with better solutions if we had a little more details
Using PHP, does anyone know how to make it so that when someone registers on a website (and therefore enters data into a database), a folder with a default php file is created on the web root/server???
This is not a good design. Rather, you should have your PHP files look at the session to find the logged in user's id, and query the necessary data about that user id. You don't need a file for each user. You can make your table auto-increment a user id.