<?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 Mariam Abdussalam on Medium]]></title>
        <description><![CDATA[Stories by Mariam Abdussalam on Medium]]></description>
        <link>https://medium.com/@omorilewa?source=rss-9c3c1a8c9f69------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*wiOahkss42vGwlYA.</url>
            <title>Stories by Mariam Abdussalam on Medium</title>
            <link>https://medium.com/@omorilewa?source=rss-9c3c1a8c9f69------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 07:41:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@omorilewa/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[Serving static and media assets/files in Django (development and production)]]></title>
            <link>https://omorilewa.medium.com/serving-static-and-media-assets-files-in-django-development-and-production-8e1224e10a3f?source=rss-9c3c1a8c9f69------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e1224e10a3f</guid>
            <dc:creator><![CDATA[Mariam Abdussalam]]></dc:creator>
            <pubDate>Tue, 02 Mar 2021 00:50:43 GMT</pubDate>
            <atom:updated>2021-03-02T00:50:43.331Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This post is targeted at beginner python(Django) developers</em></p><h3>Definition of terms</h3><p>Yes, yes! This is so cliche, but we need to do this before we dive in. I kept it short and simple.</p><p><strong>What are static assets?</strong></p><p>These are files or objects that you display to a user on your webpage that the user does not have the ability to edit(either to change or to delete them). They are displayed to the user the way you sent them. They include CSS files(*.css), video/audio files(*.mp4, *.mp3, *.webm), images such as page banners, logos(*.png, *.gif, *.jpg) or even JSON files (*.json).</p><p><strong>What are media assets?</strong></p><p>Media assets/files on the other hand are files that users are asked to upload on your application. They typically are images such as profile pictures, or documents that the user upload themselves.</p><p><strong>What does “serving” even mean?</strong></p><p>Serving files in this context means making the files available in your browser. That sounds confusing, right? The files are in your project directory already and you are probably wondering, <em>why do I even need to serve them again</em>? <br>Django does not make the files available for use in your application out of the box. The files have to be served (made available) so that it knows where to look for them</p><h3><strong>Serving static files</strong></h3><p>Django uses the <a href="https://docs.djangoproject.com/en/3.1/ref/contrib/staticfiles/#module-django.contrib.staticfiles">staticfiles app</a> to get all the static files in your application and serve them.</p><p>To add the static files app to your django project, you need to include it in the list of installed applications in your settings file. To do this you add, “<strong>django.contrib.staticfiles”</strong> to the installed apps as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*2PqocZYtKV4GgRru3uU0ww.png" /></figure><p>Since we have installed the staticfiles app, we have access to three additional management commands. If you peek at your lib folder in your .virtualenv directory, you can see the three management commands we have now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*aRt5-03ixRJfBtSlTlRMAw.png" /><figcaption>management commands in staticfiles app</figcaption></figure><ul><li><a href="https://docs.djangoproject.com/en/3.1/ref/contrib/staticfiles/#collectstatic">Collectstatic</a>: Looks for all the static files in your application and place them in the directory defined as the <strong>STATIC_ROOT</strong>(we would get to this shortly). To collect static files, run ./manage.py collectstatic in your project directory. You would see something similar to the image below that shows a summary of all static assets copied over into the STATIC_ROOT.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*F4igmCM60881bdDB6NPfNA.png" /><figcaption>running collectstatic example</figcaption></figure><ul><li><a href="https://docs.djangoproject.com/en/3.1/ref/contrib/staticfiles/#findstatic">Findstatic</a>: Find a specified static file. To do so run ./manage.py findstatic path_to_static_file</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*KrFFs4OqQ3I36vIhmg4HTQ.png" /><figcaption>running findstatic example</figcaption></figure><ul><li><a href="https://docs.djangoproject.com/en/3.1/ref/contrib/staticfiles/#runserver">Runserver</a>: if the static files app has been installed, this overrides the runserver app to include serving static files. To do this run ./manage.py runserver</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*1fpPKpi8_LVvySdc5RovJQ.png" /><figcaption>runserver example</figcaption></figure><blockquote>The commands above can also be run with django-admin instead of /.manage.py. I generally prefer using manage.py since django recommends <a href="https://docs.djangoproject.com/en/3.1/ref/django-admin/#django-admin-and-manage-py">here</a> that it is easier to use.</blockquote><p>Now that we have some knowledge of the static app, let us get to how to serve the static assets. Right before we do this, we would go through some settings variables that Django to help it store and serve our static/media files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PKDDvYDw5S3cLDEjZ7eRyA.png" /></figure><blockquote>I prepended the static url with my to help easily differentiate between the _ROOT and _URL env variables. Typically the static_url and media_url are named /static/ and /media/ respectively.</blockquote><p><strong>STATIC_ROOT</strong>: The absolute path to the folder Django should store all the static files after collecting them. In the image above, we set our static root to a folder named <strong>static</strong> within the project directory.</p><p>Once we run collectstatic, all the static assets would be in the static folder in the root directory of the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/255/1*z81kr6KcFxL51Ndb1VxC9Q.png" /><figcaption>static files example</figcaption></figure><p><strong>STATIC_URL: </strong>This is the url Django refers to when serving the files. Remember that serving simply means making the file available for use in the browser. Let us look at the screenshot below, the spinner.gif is in the images folder. The images folder is in another folder named wagtailadmin which is in the static folder. The path to the spinner would be /wagtailadmin/images/spinner.gif</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*v_Vuuml8X0m4XNFqCr6aiQ.png" /></figure><p>Since we had set our STATIC_ROOT to os.path.join(BASE_DIR, ‘static’) , which meant we told Django to place our static assets in a directory in our root folder named static. We can see that we have all our static assets.</p><p>To reference our assets in the browser, we use the STATIC_URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eK4ttALjYGyhxwqGfot2cA.png" /><figcaption>image of a static asset</figcaption></figure><p>Our spinner above would be available at<br> <a href="http://localhost:8000/mystatic/wagtailadmin/images/spinner.gif">http://localhost:8000/mystatic/wagtailadmin/images/spinner.gif</a> (You guessed right!).<a href="http://localhost:8000/mystatic/wagtailadmin/images/spinner.gif">http://localhost:8000/</a> is the url to my site. Also, note that the STATIC_URL is a relative URL.</p><h4><strong>Serving static files in development</strong></h4><p>In your development environment, typically your STATIC_ROOT and STATIC_URL are as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wfa0IF4xUYKFkjk6TTEU-w.png" /></figure><p>As mentioned previously, the STATIC_ROOT is the folder the static files would be placed, in this case, a static folder in your root directory set as BASE_DIR(Base directory). The STATIC_URL is the url prepended to the path to the static asset you are requesting.</p><h4><strong>Serving static files in production</strong></h4><p>Serving your static files in production involves</p><ul><li>Running the collectstatic command to collect your files to the <strong>STATIC_ROOT</strong></li><li>Configure your server to serve the files in your static root in from the <strong>STATIC_URL</strong></li></ul><p>It is explained in detail <a href="https://docs.djangoproject.com/en/3.1/howto/static-files/deployment/">here</a></p><p>It is also common to use cloud storage like s3 with the CDN(Content Delivery Network) providers like Cloudflare or Cloudfront. If you use this, third-party packages make it easy to have your files uploaded to s3 or any other storage provider when you run collectstatic. A popular package used for this is <a href="https://django-storages.readthedocs.io/en/latest/">django-storages.</a></p><p>Once you have django-storages all set up in their application(their documentation provides an easy-to-use guide), you can set your static URL to your CDN url.</p><p>In the screenshot below, I had installed the django-storages package and have added all the required settings in my settings file in my app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ijmoT0rg_sfuOu-DTAwrMQ.png" /><figcaption>sample settings using aws cloudfront.</figcaption></figure><blockquote>Ideally you should have an env file to store variables like the STATIC_URL and not write them directly in your settings file.</blockquote><p>In production, depending on how you have caching set up, it is likely that these assets are cached. Ensure to always serve the latest version of your assets.</p><h3>Serving media assets</h3><p>Recall we said media files are user-uploaded files. To serve our media files, we need two env variables</p><p><strong>MEDIA_ROOT: </strong>This is the path to the directory Django stores the media files.</p><p><strong>MEDIA_URL</strong>: The relative or absolute path Django uses to fetch the url to the asset.</p><blockquote>It is noteworthy to mention that the MEDIA_ROOT and STATIC_ROOT must have different values.</blockquote><h4><strong>Serving media assets in development</strong></h4><p>An example setting is shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*M652fME9Nod2rx6CYI5Gzw.png" /></figure><h4><strong>Serving media assets in production</strong></h4><p>An example setting is shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tckRDfLn6YsLsNl8MG3mGQ.png" /></figure><p>I hope we have learnt one or two things from this write-up, let me know your thoughts or questions if any!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e1224e10a3f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[As the most intelligent and adaptable species on earth, i had always believed i had the innate…]]></title>
            <link>https://omorilewa.medium.com/as-the-most-intelligent-and-adaptable-species-on-earth-i-had-always-believed-i-had-the-innate-7d813a65b8d2?source=rss-9c3c1a8c9f69------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d813a65b8d2</guid>
            <category><![CDATA[andela]]></category>
            <category><![CDATA[andela-bootcamp]]></category>
            <dc:creator><![CDATA[Mariam Abdussalam]]></dc:creator>
            <pubDate>Mon, 05 Dec 2016 09:14:57 GMT</pubDate>
            <atom:updated>2016-12-05T09:14:57.969Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>“The measure of intelligence is the ability to change “ — Albert Einstein.</blockquote><p>As the most intelligent and adaptable species on earth, i had always believed i had the innate ability to adjust to any form of change. However, the andela journey has been the most interesting one thus far.</p><p>It has been a topsy-turvy ride.From the initial moments of struggling to solve all the homestudy curriculum labs(with php at the time), to the interview, and then the first self-learning clinic(SLC). I vividly remember walking onto the amity campus penthouse crossing my fingers that it would just go as planned. I met the members of my group and tried to establish relationships.</p><p>As the day started, a graceful looking man came to the front of the group to start our session, he was the boot camp facilitator, his name was Phillip.We started with the soft skills session, and all was going well, up until he mentioned that we were going to using JavaScript. I WAS STARTLED. Where was i going to start this from. Then i remembered the soft skill session on the growth mindset and i became positive about it. Swiftly i went through some java script documentation and it was way easier than i thought.</p><p>The day went on well and we were given some tasks to submit the next day which i was able to. Afterwards, we were going to be doing our homestudy. As Having acclimatized myself with test driven development, it seemed a lot easier, the first day labs were quite understandable. The second day labs suddenly needed us to use API’s. At the time, the only thing i knew about API’s was the full meaning was “Application programming interface”. I started out my research and it got to understand it.At that point i appreciated how much i had grown to be able to adapt to any situation i found myself.</p><p>I was invited to the second self learning clinic ,where i had to work in a team to get a project presented, i appreciated simple concepts like listening, effective communication,feedback and politeness as we solved the problem ahead of us. At the end of the day,we were told we would be informed if we would make it into the second week of the boot camp.</p><p>It was a sunny Saturday afternoon, i was taking a nap,my phone beeped twice.As i picked up to check it, it was a mail from andela. The sleep immediately cleared from my eyes. My heartbeat has started increasing. I was visibly shaking as i opened the mail. I leaped joyfully. I was going to week 2 of boot camp. I look forward to the week ahead.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d813a65b8d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Wow…..I survived another day at bootcamp.]]></title>
            <link>https://omorilewa.medium.com/wow-i-survived-another-day-at-bootcamp-4b73f3b61f52?source=rss-9c3c1a8c9f69------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b73f3b61f52</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Mariam Abdussalam]]></dc:creator>
            <pubDate>Wed, 30 Nov 2016 16:48:34 GMT</pubDate>
            <atom:updated>2016-11-30T16:48:34.456Z</atom:updated>
            <content:encoded><![CDATA[<p>Wow…..I survived another day at bootcamp.</p><p>Still stunned at new things i have suddenly become a master at (github,git ,javascript, test driven development, node.js). I can only imagine how much more i would learn if i consistently did this for a month or even a year.</p><p>As usual, i woke up to the task ahead of me. Making a simple web page (not so simple after all) was what i set out to do amidst other tasks. It was interesting to replicate a webpage. I have enjoyed the learning process so much.</p><p>My recent experiences has made me grow and trust more in myself.</p><p>Finally…i believe i can make it into andela. I am pumped as ever as i look forward to tomorrow.</p><p>Its all about a continuous learning process.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b73f3b61f52" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Boot camp Day 2]]></title>
            <link>https://omorilewa.medium.com/boot-camp-day-2-18ed80a9fe98?source=rss-9c3c1a8c9f69------2</link>
            <guid isPermaLink="false">https://medium.com/p/18ed80a9fe98</guid>
            <category><![CDATA[andela]]></category>
            <category><![CDATA[andela-bootcamp]]></category>
            <dc:creator><![CDATA[Mariam Abdussalam]]></dc:creator>
            <pubDate>Tue, 29 Nov 2016 15:26:54 GMT</pubDate>
            <atom:updated>2016-11-29T15:26:54.515Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Boot camp Day 2</strong></p><p>As i woke up in the morning, i felt a sting of excitement. Then i remembered, it was my second day at Andela Boot camp. Boot camp had become more interesting. As i settled in to start my task for the day, i ensured i was time conscious and i had previously struggled with that. As i concluded, i peeked at the wall clock hanging in my room as i heaved a sigh of relief. Pheeeewwwww…….I was done before my 4:30pm deadline.</p><p>Today, it was about consuming Application Programming Interface (API) and writing wordcount and maxandmin labs.</p><p>I always heard about API’s and somewhat thought it sounded rather complicated or was going to be difficult to comprehend. The task today required using an API, i had no choice but to get up to speed with using them. I learnt about http client library in JavaScript. i used ‘request” as its a simple http client. I used a simple short message service (sms) API to create a command line application that sends sms for free(Not really free though!!!).</p><p>It was satisfying to see the sms drop on my phone and several other numbers i had included in my lab.During the course of solving the task, i appreciated how much i had grown in recent days.</p><p>As i submitted, i remembered my friend Lara&#39;s reaction as i mentioned to her that i would be applying to andela. “Haaa!!!! she screamed, they say its almost impossible to enter andela”.</p><p>It may be as difficult as she thinks but certainly possible. I look forward to Boot camp day 3.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18ed80a9fe98" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[So far, Day1 has been demanding, from mastery git to test driven development.]]></title>
            <link>https://omorilewa.medium.com/so-far-bootcamp-has-been-demanding-from-learning-ca679b224f71?source=rss-9c3c1a8c9f69------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca679b224f71</guid>
            <dc:creator><![CDATA[Mariam Abdussalam]]></dc:creator>
            <pubDate>Mon, 28 Nov 2016 15:36:07 GMT</pubDate>
            <atom:updated>2016-11-28T15:39:51.876Z</atom:updated>
            <content:encoded><![CDATA[<p>So far, Day1 has been demanding, from mastery git to test driven development. I immediately started working with the problems from the beginning of the day but struggled with ensuring the tests passed.</p><p>Eventually they did and i have had a constant battle with time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca679b224f71" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>