Code Monkey home page Code Monkey logo

py-blog's Introduction

Blog

In this task, you will create a simple Blog project from start to end.

Let's go through all the steps:

  1. Create a virtual environment, activate it, and install django via pip.

  2. Start project blog_system inside the current directory (add . at the end of the command).

  3. Inside py-blog start application blog.

  4. Inside blog/models.py create models according to this diagram:

    models-diagram

  5. Edit admin.py:

    • Register all your models in the admin.
    • Unregister Group (you can make it with admin.site.unregister(Group) by importing Group from django.contrib.auth.models).
    • Do the filtering and searching in any way you think is logical.
  6. Make migrations and migrate.

  7. Use python manage.py test to run tests.

  8. Use the following command to load prepared data from the fixture to test and debug your code: python manage.py loaddata blog_system_db_data.json

    Feel free to add more data using the admin panel if needed.

  9. Inside blog_system.urls add a path to the blog.urls. Don't forget to specify the namespace.

  10. Inside blog.urls create a path for the home page. Give this path the name index.

  11. Inside blog.views create a view for the index url. This view returns a list of all posts, in descending order by created_time.

  12. Before creating a template, you have to create styles. Create a directory static next to the directory blog. Inside this directory create a file with the following path css/styles.css. Don't forget to do all the necessary steps so that Django can serve these static files.

  13. Create a directory templates next to the directory blog. There you will store templates for pages. Edit settings so that engine knows where to look for template source files.

  14. Create a template for the main page. On this page, make it so that a list of all posts is displayed. The title and content were displayed, the author was visible when this post was created and the number of comments on the post. Make the post's title a link to the detailed page, which you would implement further.

  15. Add pagination for the main page. Set 5 posts on one page by default.

  16. Create a PostDetailView view that returns detailed information about the post by the id field.

  17. Add a template for this page and url with a path posts/pk/ and name post-detail.

  18. On the post detail page, display a list of post comments below this post.

  19. Under the list of comments, add a form that allows you to create a new comment to the post.

Please note: only authorized users can post comments. If an anonymous user tries to create a new comment, the form must be invalid.

  1. Use crispy forms in your forms to make the website more beautiful.
  2. Use python manage.py test to run tests.
  3. Don't forget to add the .gitignore file before pushing. Don't push a lot of extra files(venv, pycache, .idea, etc.).

Note: Attach screenshots of all created or modified pages to pull request.

  1. Attach screenshots to the comment, NOT in the commit.
  2. It's important to attach images not links to them.

Example of the post detailed page

Notice: that example is not a reference! You can make this page in another way.

post-detailed-page-reference-1 post-detailed-page-reference-2 post-detailed-page-reference-3

py-blog's People

Contributors

nattalli avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.