<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Anandhakumar Radhakrishnan on Medium]]></title>
        <description><![CDATA[Stories by Anandhakumar Radhakrishnan on Medium]]></description>
        <link>https://medium.com/@rkanandhakumar?source=rss-675603b2efca------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*qtbqJ7YqeSOmXUku.</url>
            <title>Stories by Anandhakumar Radhakrishnan on Medium</title>
            <link>https://medium.com/@rkanandhakumar?source=rss-675603b2efca------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 04:27:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rkanandhakumar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Django Sass Integration and Database Seeds]]></title>
            <link>https://medium.com/@rkanandhakumar/django-sass-integration-and-database-seeds-9341ef9b448f?source=rss-675603b2efca------2</link>
            <guid isPermaLink="false">https://medium.com/p/9341ef9b448f</guid>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[seeds]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[sass]]></category>
            <dc:creator><![CDATA[Anandhakumar Radhakrishnan]]></dc:creator>
            <pubDate>Wed, 18 Apr 2018 09:01:53 GMT</pubDate>
            <atom:updated>2018-04-18T09:01:53.654Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*BBX0QJ8i0YmwvnfUCVK7cg.jpeg" /></figure><h3>Introduction</h3><p>I have tried some python modules which supports sass, but when I integrated that local development becomes very slow. The compass compiler would take more time to execute. Later I combined the three components Django, Sass and Webpack for a speedy process.</p><p><strong>Pros</strong></p><p>Front end developers will create HTML, Sass template, and Django developers will integrate with compiled assets. We suppose to maintain two repositories and also we have to maintain same versions in both repositories if not we have the face the version complexity.</p><p><strong>Cons</strong></p><p>In this architecture we have merged both UI and Django development. Here we have only one repository and we don’t need to run collectstatic for any file changes, webpack watch will take care of that.</p><p>Here we don’t need to run collectstatic. Will maintain all the assets in the root and in Django settings point the STATIC ROOT to the respective directory.</p><h3>Dependencies</h3><p>If you don’t have node js in your machine, please install <a href="https://nodejs.org/en/download/">node j</a>s.</p><p>Here my <a href="https://github.com/anandhakumarr/django_sass_intg">Source code</a>. Please clone this code and reuse it.</p><p>For all development dependencies I have added to the installation script <a href="https://github.com/anandhakumarr/django_sass_intg/blob/master/install.sh">install.sh</a>. This will install your application and environment related stuffs.</p><h3><strong>Sass integration</strong></h3><p>Create a package.json file and add your node module dependencies. For example I have added all Jquery and bootstrap related things.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*uQsdqtfyrMmiHsJKTpBFZg.png" /><figcaption>Webpack Dependencies</figcaption></figure><p>Here you would see the index.js is the entry point for this application.</p><p>Run <em>“npm install”</em> which will create a new folder named ‘node_modules’ and install all the packages. We don’t need this in our repository so add it in git ignore.</p><p><strong>Folder Structure</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*48-6D5XBFLYAJcM_1S0g0A.png" /><figcaption>Sass + Django Folder structure</figcaption></figure><p>Since index.js is the entry point I added all the sass and js files here.</p><p>I have added bootstrap and Jquery from node_modules.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*tmpDZY_86vQqAbeQJ9GR3g.png" /></figure><p>I have added scripts here, using this we will start both webpack and django. Here look at the “start” key will build the package and watch if any changes and “python runserver” would start the application.</p><p>“npm run prod”<em> which will create compressed version of static files to run this use the below command.</em></p><h4>Webpack and Static Files Configuration</h4><p>Django we do use collectstatic to get all the static files from all apps and added to staticfiles directory.</p><p>Here we don’t use collectstatic, we will create new folder called staticfiles you can add all your images, fonts and other libraries.</p><p>Webpack will compile and move to our new static file location.</p><p>Webpack compiler will point the index js as entry point and compile all the files and this will create new files (app.css and app.js). All the assets will compressed if it a production enviroment. Here all the assets files will moves to staticfiles/static/ directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W97iC0IwbKPuFeUxMh4LvA.png" /></figure><p>In Django settings we addeed the static roots as</p><blockquote>STATIC_URL = ‘/static/’</blockquote><blockquote>STATICFILES_DIRS = [ os.path.join(BASE_DIR, ‘staticfiles/static’), ]</blockquote><blockquote>STATIC_ROOT = ‘/static’</blockquote><p>Finally run “npm start” will start the Django application and complie all the js and sass files. Webpack will keep on watching. If any changes it will compile and move the assets very quickly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S7n727PLW7yBQyTYGlyZTQ.png" /></figure><p>If you have any errors in the js/sass you can see from the termial itself.</p><h3>Populating the Database with seeds</h3><p>This is an easy way of feeding default values easily and quickly to a fresh installation. Sometimes we need reference data to run the application, Instead of exporting and importing into the database we can create seeds.</p><p><strong>Generating seeds From Existing Data</strong></p><blockquote>“python manage.py dumpdata default.ContentTemplates &gt; seeds/contentTemplates.json”</blockquote><p><strong>Importing data from seeds</strong></p><blockquote>“python manage.py loaddata seeds/contentTemplates.json”</blockquote><p>You can also modify the seed files.</p><h3><strong>Conclusion</strong></h3><p>All the sass components we can easily reuse it. Seeds will always useful when you go for initial production. So it’s worth it to invest some time to learn and practice.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9341ef9b448f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>