I'm new to django and I wonder if there is anyway to use initial data without reinstalling custom sql each time. My initial data is almost 100MB and it's kind of painful to wait for database import for each test. I'm trying to find a way to do it without truncating my initial data.
Asked
Active
Viewed 37 times
0
-
1Are you looking for this? http://djangosnippets.org/snippets/1318/ – karthikr Jun 25 '13 at 15:37
-
That's exactly what I wanted, thanks. – eneepo Jun 25 '13 at 15:47
-
1Also, I'm offering a django class for newbies this fall if you're interested http://skl.sh/17FtUju – Sid Jun 25 '13 at 16:03
2 Answers
1
Why don't you cache your data? You can either do that in process as a global variable. Depending on how you are running your server - multithreaded, multiprocessed, both - WSGI/Embedded - this may be easy or hard.
Another option is to use memcached.
Django caching is described here
- https://docs.djangoproject.com/en/dev/topics/cache/
- http://www.jeffknupp.com/blog/2012/02/24/django-memcached-optimizing-django-through-caching/
It's very easy to use it. The interface is simply a get(key) and set(key,value). You can use various kinds of caches:
- Filesystem (you should probably use this with multiple processes)
- In memory (for single process and single thread try this - will be faster)

Sid
- 7,511
- 2
- 28
- 41
-
As I said I'm a newbie and what you said is kind of challenging, I'd really appreciate if you recommend some helpful articles. I haven't read django doccmentaion on chaching is it enough to establish what you said? – eneepo Jun 25 '13 at 15:52