I'm making a django project where there is the need to use information from an ApiRest. To manage the information more easily I created classes to get the info and display it.
Since my classes aren't django models the relashionships between those and my database take a lot of work and will break with each change I make. So I want to use a custom database backend instead of the classes. But there I cant find any documentation on how it should be done.
Is there a place where I can find the documentation of how a database engine works in django?
I have already looked in the django docs but there is no article or section about database engines. Or I couldn't find it.
edit: added info
I'm looking to do something similar - Creating a custom database engine using pyodbc.
I found
https://www.youtube.com/watch?v=tkwZ1jG3XgA
https://simpleisbetterthancomplex.com/media/2016/11/db.pdf and
https://reinout.vanrees.org/weblog/2016/11/04/database-backends.html
as good documentation starting points.
Then I created https://pypi.org/project/django-filemaker-pyodbc/0.0.1/ after going through the documentation and reading through django_pyodbc
Related
I have a simple script that creates a unique one time only disposable hash and I was hoping to just add it to my existing django site as this tool is for the people that use the site.
I can find nothing at all on google about this and it seems a shame to have to create a completely separate website just to provide a GUI for a simple 5 line script.
I have a list of posts with a title and descrption. I have found the full text search documentation for postgres database here. But this is not useful for me as I am presently using sqlite3 database.
What are my options to have a similar functionality for my sqlite3 db?
Since full-text-search is a database(PgSQL) specific tool, Django doesn't natively support for full text search in sqlite database,
Read more on Searching in other databases
All of the searching tools provided by django.contrib.postgres are constructed entirely on public APIs such as custom lookups and database functions. Depending on your database, you should be able to construct queries to allow similar APIs. If there are specific things which cannot be achieved this way, please open a ticket.
More: https://docs.djangoproject.com/en/2.0/topics/db/search/#a-database-s-more-advanced-comparison-functions
I have followed various posts and tutorials but couldn't find anything that is relevant. I found a ORM for rethinkdb "https://github.com/dparlevliet/rwrapper" but don't know how to use it?
I am new to to django and python.
It depends on what you want to do.
There is no way to simple replacement of Django's ORM with RethinkDB now. However, working with RethinkDB driver is simple enough, and similar to how you would use Django ORM.
The nearest thing is indeed rwrapper, you can try starting with this tutorial.
If you don't need to use Model classes, then you just need to find a place to connect to database (or use some sort of Singleton or Factory to connect to the database), and then just import rethinkdb as r and r.connect() and then just write queries with ReQL.
If you need realtime data, then Django is not suitable for that at all. You can consider mixing Django with Tornado
Django doesn't support RethinkDB at the moment and I don't think there's any plan for it as well.
Django developers don't add new stuff to the code base just because it's something new and might be cool. It should be really well mature and a high needs for it. So, I don't think you'll be hearing anything about RethinkDB from Django devs anytime soon.
This project might be something interesting:
https://github.com/thejsj/django-and-rethinkdb
In order to use any database with Django, the adapter should completely be a Django DB Backend in order to work with:
Models
Admin
Forms
Various Class Based Forms
Session
Auth
etc...
In others words, as long as the db backend doesn't support all the django database operations is not something that you wanna use.
I am using SOLR with NUTCH
I have successfully configure both and Solr is giving me the desired results
Now i want to integrate this in my Django project
Can anyone suggest me how to do it ...
it depends on what you need:
IF YOUR SOLR INSTANCE IS BOUND TO THE DJANGO'S MODEL
you probably are looking for django-haystack: it's pretty easy to setup and to use inside your django views, but it's not suited for huge amount of data
IF YOU'RE USING SOLR WITHOUT ANY RELATION TO DJANGO MODELS
this means that your results are retrieved as pure array, and you just need a python interface to solr. you have some choices
pysolr
solrpy
sunburnt (i'm using this)
you have to try them out and find out which one satisfies you more (check their websites too, to see if the project is mantained. also, stumble into their source code, to check if there's all you need). being a python interface implies that you have to do a little bit more of work inside your views
i hope this can help you
What would be the best way to port an existing Drupal site to a Django application?
I have around 500 pages (mostly books module) and around 50 blog posts. I'm not using any 3rd party modules.
I would like to keep the current URLS (for SEO purposes) and migrate database to Django. I will create a simple blog application, so migrating blog posts should be ok. What would be the best way to serve 500+ pages with Django? I would like to use Admin to edit/add new pages.
All Django development is similar, and yours will fit the pattern.
Define the Django model for your books and blog posts.
Unit test that model using Django's built-in testing capabilities.
Write some small utilities to load your legacy data into Django. At this point, you'll realize that your Django model isn't perfect. Good. Fix it. Fix the tests. Redo the loads.
Configure the default admin interface to your model. At this point, you'll spend time tweaking the admin interface. You'll realize your data model is wrong. Which is a good thing. Fix your model. Fix your tests. Fix your loads.
Now that your data is correct, you can create templates from your legacy pages.
Create URL mappings and view functions to populate the templates from the data model.
Take the time to get the data model right. It really matters, because everything else is very simple if your data model is solid.
It may be possible to write Django models which work with the legacy database (I've done this in the past; see docs on manage.py inspectdb).
However, I'd follow advice above and design a clean database using Django conventions, and then migrate the data over. I usually write migration scripts which write to the new database through Django and read the old one using the raw Python DB APIs (while it is possible to tie Django to multiple databases simultaneously, too).
I also suggest taking a look at the available blogging apps for Django. If the one included in Pinax suits your need, go ahead and use Pinax as a starting point.
S.Lott answer is still valid after years, I try to complete the analysis with the tools and format to do the job.
There are many Drupal export tools out of there by now but with the very same request I go for Views Datasource choosing JSON as format. This module is very solid and available for the last version of Drupal. The JSON format is very fast in both parsing and encoding and it's easy to read and very Python-friendly (import json).
Using Views Datasource you can create a node view sorted by node id (nid), show a limited number of elements per page, configure a view path, add to it a filter identifier and pass to it the nid to read all elements until you get an empty JSON response.
When importing in Django you have a wide set of tools as well, starting from loaddata to load fixtures. Views Datasource exported JSON but it's not formatted as Django expects fixtures: you can write a custom admin command to do the import, where you can have the full control of the import flow.
You can start your command passing a nid=0 as argument and then let the procedure read, import and then fetch data from the next page passing simply the last nid read in the previous HTTP request. You can even restrict access to the path on view but you need additional configuration on the import side.
Regarding performance, just for example I parsed and imported 15.000+ nodes in less than 10 minutes via a Django 1.8 custom admin command on an 8 core / 8 GB Linux virtual machine and PostgreSQL as DBMS, logging success and error information into a custom model for each node.
These are the basics for import/export between these two platform, for detailed information I described all the major steps for export from Drupal and then import to Django in this guide.