Skip to content

This repo contains simple and complex Django App that I Implement while learning Django web framework

Notifications You must be signed in to change notification settings

karimikiura/Django_Journey

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django_Journey

This repo contains simple and complex Django App that I Implement while learning Django web framework

Projects

HelloWorld App

This is a simple hello world app in Django.
Learned to:

  • Create function based views
  • Use HttpResponse to return http request to client
    fun homePageView(requests):
        return HttpResponse("Hello, World)

Pages App

A simple app that has two pages. The index and about.html pages.
Learned how to return these pages using class based views.

    from django.views.generic import TemplateVew
    class HomePageView(TemplateView):
        template_name = 'home.html'

Learnt to create simple test cases for the basic app.
"Code without tests is broken as designed"~J.Kaplan Moss
Used SimpleTestCase that lets testing without lookup on the database.

from django.test import impleTestCase

class SimpleTestCase(SimpleTestCase):
    def test_homepage_status_code(self):
        response = self.client.get('/')
        self.assertEqual(response.status_code, 200)


    def test_about_page_status_code(self):
        response = self.client.get('/about/')
        self.assertEqual(response.status_code, 200)

To run the tests, run:
python manage.py test

Message Board

A simple app that implements models with SQLite database. Uses the TemplateView to List all Posts stored in the database using TestCase.
The app also tests the following\

  1. PostModel
class PostModelTest(TestCase):

    def setUp(self):
        Post.objects.create(title="Sublime or Vs Code?", text="Code editor wars.")

    def test_text_content(self):
        post = Post.objects.get(id=1)
        expected_object_text = f'{post.text}'
        self.assertEqual(expected_object_text, 'Code editor wars.')
  1. PostTitle
class PostTitleTest(TestCase):
    def setUp(self):
        Post.objects.create(title="Sublime or Vs Code?", text="Code editor wars.")

    def test_post_title(self):
        post = Post.objects.get(id=1)
        expected_object_text = f'{post.title}'
        self.assertEqual(expected_object_text, 'Sublime or Vs Code?')
  1. HomePageView
class HomePageViewTest(TestCase):

    def setUp(self) :
        Post.objects.create(title="Cloud wars", text="AWS leads GCP and Azure to dominate the cloud market")
    
    def test_view_url_exists_at_proper_location(self):
        response = self.client.get('/')
        self.assertEqual(response.status_code, 200)

    def test_view_url_by_name(self):
        resp = self.client.get(reverse('home'))
        self.assertEqual(resp.status_code, 200)

    def test_view_uses_correct_template(self):
        resp = self.client.get(reverse('home'))
        self.assertEqual(resp.status_code, 200)
        self.assertTemplateUsed(resp, 'home.html')

9/15/2022

[9/16/2022]

Blog App

A simple blog app that implements CRUD operations.\

Unit Tests

unit-tests create its own database which is empty.
django.test.Client dummy Web browser for simulating GET and POST requests on a URL.\

TODO

[x] Fix

    self.assertEqual(response.status_code, 200)
    AssertionError: 404 != 200
on `def test_post_detail_view(self):` test\

[ ] Use form widgets
[ ] Use crispy forms
[ ] Use bootstrap or Tailwind to style
[ ] Create user dashboard\

News App

Todo

  • Celery to handle email resets
  • Allauth - To integrate with third parties

About

This repo contains simple and complex Django App that I Implement while learning Django web framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published