Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm not sure 'What' functionality you are talking about. If you mean 'searching keywords from a dictionnary that is recorded in your database', then <code>python dictionnary</code> is not a possible solution, as you would have to deserialize your whole database in order to make a search.</p> <p>You should rather look towards the django 'search' applications. A lot of people advise to use <code>haystack</code> :</p> <p><a href="https://stackoverflow.com/questions/55056/whats-the-best-django-search-app">What&#39;s the best Django search app?</a></p> <p>and use this search engine to look for some keyword in your database.</p> <p>If you don't want to support sophisticated searches, then you could also query for an exact keyword in your database </p> <pre><code>DictEntry.objects.get(keyword=`something`).definition </code></pre> <p>I guess it all depends on the level of sophistication you want to achieve, but there can be extremely simple solutions.</p> <p>EDIT :</p> <p>If the dictionnaries come from files, then it's hard to say, you have plenty of solutions.</p> <p>If the file is small, you could indeed deserialize it to a dictionnary when starting the server, and then always search in the same instance (so you wouldn't have to deserialize again for each request).</p> <p>If the files are really big, you could consider migrating them to your database.</p> <p>1) First create your Django <strong>models</strong>, so you would know what data you need, the name of your fields, etc... for example :</p> <pre><code>class DictEntry(Model): keyword = CharField(max_length=100) definition = CharField(max_length=100) </code></pre> <p>2) It seems like some of the files on the link you gave are in csv format (it seems also like you can have them in xml). With the <a href="http://docs.python.org/library/csv.html" rel="nofollow noreferrer">csv</a> module from standard library, you could extract these files to python.</p> <p>3) and then with the json or yaml python libraries, you dump these files back to a different format (json or yaml) as described in <a href="http://docs.djangoproject.com/en/dev/howto/initial-data/" rel="nofollow noreferrer">initial data for your model</a>. And <strong><em>magic</em></strong> your initial data is ready !</p> <p>PS : the good thing with python : you google 'python json' you will find the official doc because a library for writing/reading json is part of the standard python lib !!! Idem with xml and csv ...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload