Momentum logo
Team 10 Classroom

๐Ÿป File Upload with Django and DRF ๐Ÿป

Posted on Dec 21st, 2021

๐Ÿ—“๏ธ Todayโ€™s Topics

  • Project Progress
  • File Uploads

๐Ÿ”– Resources

File uploads

POST with upload using Insomnia

  • Choose binary file attachment from the JSON menu (where you normally put the body of a request)
  • Headers (this example assumes an image file in jpeg format, named profile-photo .jpg):

    Content-Type: image/jpeg
    Content-Disposition: attachment; filename=profile-photo.jpg
    

For more information on the values for Content-Type:

CORS for file upload

Assuming you are using django-cors-headers, youโ€™ll need to add the following to settings.py:


from corsheaders.defaults import default_headers

CORS_ALLOW_HEADERS = list(default_headers) + [
    'content-disposition',
]

๐Ÿ“– Read | ๐Ÿ“บ Watch | ๐ŸŽง Listen

๐ŸฆŠ Project Progress Check-In ๐ŸฆŠ

Posted on Dec 20th, 2021

๐Ÿ—“๏ธ Todayโ€™s Topics

How are the projects coming along? ๐Ÿ‘€

Keep pushing forward! ๐Ÿ’ช ๐Ÿš€

Todayโ€™s class is devoted to getting you past any blockers you may be experiencing and to talk through next steps.

Minimum requirements are listed below for reference.

๐ŸŽฏ Project due on Wednesday afternoon

๐Ÿ‘‰ If your project meets minimum requirements today, HUZZAH! That is awesome. You should be working on at least one spicy feature.

๐Ÿ‘‰ If your project does not yet meet minimum requirements, you should shoot for meeting them by the end of the day tomorrow.

All projects

  • Users can login, logout, and register
  • Auth token is saved in local storage

QuestionBox, Front End

  • Any user can see all questions and answers
  • A user can post a question; questions cannot be edited (editing can optionally be allowed on unanswered questions)
  • A user can post an answer to a question
  • A user can mark an answer to a question they posted as โ€œacceptedโ€
  • A user can see a list of all their own questions and all their own answers
  • A user can star/favorite questions or answers

Social Cards, Front End

  • Show cards from all users
  • A user can see all their own cards
  • A user can design and create a new card
  • A user can follow another user
  • A user can see cards from a user they follow
  • A user can see a list of users they follow

๐Ÿ”– Resources

๐Ÿป ๐ŸฆŠ End of Phase Video Presentation ๐ŸฆŠ ๐Ÿป

Posted on Dec 20th, 2021

๐Ÿ“น End of Phase Presentations

This week each of you will record a short video screencast on a topic of your choice. The video should be 4-5 minutes long.

Your target audience is a brand new Momentum student who is just at the beginning of Phase 3. Imagine you are teaching them how to do what youโ€™ve done in this project. Give them the benefit of your experience over these past several weeks.

This video does not have to be polished, scripted, or edited. But I should be able to follow what youโ€™re saying and understand the points you are making.

I suggest using Loom โ€“ itโ€™s very simple to use for screencasts and for camera videos and will let you share your video easily. The free account also limits your videos to 5 minutes, so it should help you with timing!

Loom lets you record a screencast with or without your face showing. You can choose according to your preference.

Please post your video and share the url for it using this form. Your videos are due by 4:00 pm on Wednesday, Dec 22.

๐Ÿป Back End Guidelines

Your target audience is another beginner developer who is familiar with Django but not with DRF, Postgres, or Heroku. Please pick one of these topics.

  1. Pick 1-3 endpoints in your application and talk about how you implemented them. Did you make any interesting decisions or customizations along the way? You might touch on at least some of these topics: the url patterns; the HTTP methods that are handled; serializers; permissions; querysets and any filtering you may have done.
  2. Explain serializers, using examples in your app. Show us the serializer code and explain how it relates to models and how it is used in views. Point out any customizations you made and explain why you made them. Show an example JSON response using Insomnia or the browsable API from DRF.
  3. What is the most interesting specific feature or technical detail that you implemented for this project? Walk us through its functionality and implementation.

๐ŸฆŠ Front End Guidelines

Your target audience is another beginner developer who is familiar with JavaScript but not with React or Netlify. Please pick one of these topics.

  1. Explain the routing in your app. What urls does your app have? How do you handle navigation from component to component. Give us an overview of React Router and how youโ€™ve used it.
  2. Walk us through one of the components in your app and explain how it works. Topics you might touch on: what the purpose/responsibility of the component is; what component renders it and what props it receives from its parent; any state the component has and what that state is for; any events that component handles; any hooks used in the component besides useState (e.g. useEffect, useRef, useLocalStorageState).
  3. Build a new teeny tiny React application from scratch and talk us through some of the basics. You can start after creating a new create-react-app application and npm installing all the things; you can start in an App.js that is rendered via an index.js or main.js. Your application should have one component with an input form that echos whatever your user types and displays it on the page in real time. If you want to get fancier than this, you can โ€“ just keep it under 5 minutes.

๐Ÿป Search & Automatic Deploys ๐Ÿป

Posted on Dec 20th, 2021

Todayโ€™s Topics

  • Postgres full-text search
  • Automatic deploys with Herokuโ€™s GitHub integration

๐ŸŽฏ Project due on Wednesday afternoon

๐Ÿ‘‰ If your project meets minimum requirements today, HUZZAH! That is awesome. You should be working on at least one spicy feature.

๐Ÿ‘‰ If your project does not yet meet minimum requirements, you should shoot for meeting them by the end of the day tomorrow.

Note

Depending on how youโ€™ve constructed your API, you might have separate endpoints for all of the below, or you might have fewer endpoints (for instance, if you nested answers in the question detail endpoint). What matters is that you have endpoints your front-end team can use to access this data, and they are documented somewhere.

QuestionBox, Back End

  • login, logout, and register
  • list all questions and answers
  • create a question
  • create an answer
  • mark an answer to own question as โ€œacceptedโ€
  • list of all questions and all answers for an authenticated user
  • star/favorite questions or answers

Social Cards, Back End

  • login, logout, and register
  • list all cards
  • list all cards for a user you follow
  • list all cards for an authenticated user
  • create a new card
  • follow/unfollow another user
  • list all users an authenticated user follows

๐Ÿ“– Read | ๐Ÿ“บ Watch | ๐ŸŽง Listen

๐Ÿ”– Resources

@action decorator in ViewSets

๐Ÿฆ‰ Code & Notes

  • DRF Library API
  • Notes on Django Queries These are the same notes you may have seen at the beginning of the Phase. Iโ€™m including them here for easy reference, as they show examples of queries and filters that might come in handy for search endpoints.

๐ŸฆŠ URL Routing in React ๐ŸฆŠ

Posted on Dec 16th, 2021

Todayโ€™s topics

  • React Router โญ v6
  • Using local storage with state to store an auth token

๐ŸŽฏ Project

Continue planning with your team on tackling the Questionbox or Social Ecards projects. By Friday, you should be able to make requests for questions and answers if you are working on Questionbox or make requests for getting or creating cards. Deploy to Netlify as soon as possible (Tip ๐Ÿ’ก: Your code needs to run locally with no errors before you can deploy it!).

๐Ÿ“– Read | ๐Ÿ“บ Watch | ๐ŸŽง Listen

โš ๏ธ These two resources are for older versions of React Router, so you will see some outdated syntax. For instance Switch, Redirect, and the component prop on Route exist only in versions of React Router earlier than version 6. However, the main concepts are the same, so these resources can still help you understand the context and usage of React Router.

๐Ÿ”– Resources

๐Ÿฆ‰ Code