Anúncio

Backend Development - Django

29 de Mar de 2023
Anúncio

Mais conteúdo relacionado

Similar a Backend Development - Django(20)

Anúncio

Backend Development - Django

  1. Django/ Python Development
  2. About me Senior Software Engineer/ Team Lead
  3. Why Django? • Easy to Use • It’s fast and simple • Excellent Documentation • It’s secure • It suits any web application project
  4. Disadvantages Monolithic Not suited for small-scale projects No default support for WebSockets.
  5. Framework features: Templating Engine Object-relational mapper (ORM) URL routing Authentication Internationalization. Admin Panel A wide variety of ready-to-use libraries
  6. EventBrite Bitbucket Pinterest Instagram The Washington Post
  7. Schedule a job (Redis Queue) is a simple Python library for queueing jobs and processing them in the background with workers. It is backed by Redis and it is designed to have a low barrier to entry. It should be integrated in your web stack easily. Installations: Pip install rq-scheduler
  8. Schedule a job • Example
  9. Questions TIPS
  10. Tips for better programming • Source <venv> • Pip install –r requirements.txt • Python manage.py migrate • Python manage.py runserver Have a quickstart script
  11. Tips for better programming Write Tests Update Tests Add more Tests
  12. Use environment variables for settings
  13. Handling Settings for Multiple Environments
  14. Use Continuous Integration
  15. Discussions
  16. Explain user object in the Django admin system with its 3 flags?
  17. Complex Queries! How can you handle Oring operations in the queryset Example: Fetching created items today and yesterday: items= Item.objects.filter (models.Q(created_at=today) | models.Q(created_at=yesterday) )
  18. Optimize Database Calls with Prefetch Related and Select Related Usage: prefetch related: fetch a reverse foreign key or a many to many relationship. select related: when we want to fetch a foreign key or a one to one relationship.
  19. Optimize Database Calls with Prefetch Related and Select Related Usage: prefetch related: fetch a reverse foreign key or a many to many relationship. select related: when we want to fetch a foreign key or a one to one relationship.
  20. Annotate Querysets to Fetch Specific Values Annotating a queryset enables you to add attributes to each object in the queryset. Annotations can be a reference to a value on the model or related model or an expression such as a sum or count. Example: Appointment.objects.filter(status=..).annotate(appointment _length=F("end_time") - F("start_time"))
  21. Annotate Querysets to Fetch Specific Values Annotating a queryset enables you to add attributes to each object in the queryset. Annotations can be a reference to a value on the model or related model or an expression such as a sum or count. Example: Appointment.objects.filter(status=..).annotate(appointment _length=F("end_time") - F("start_time"))
  22. Code Review (1) https://github.com/Jd2020D/food2eat Jehad Al-Terawi Yasmeen Muhtaseb Mahmoud Khateeb Does this line of code have any issue?
  23. Code Review (2) https://github.com/Jd2020D/food2eat What if more than one item have the same name? Do we have any other mechanism to check the item? What type of exception raised here?
  24. Code Review (3) https://github.com/Jd2020D/food2eat Why you are getting the last order only? Optimization! Return list of Queryset Meal.objects.filter(meal__id=meal_id,items__order__user__id=?).values() Return list of ids Meal.objects.filter(meal__id=meal_id). values_list(id', flat=True)()
  25. Code Review (4) https://github.com/Jd2020D/food2eat Duplication!!!!!!!!! - Base model (abstract) - django-model-utils - TimeStampFields, Softdelete, Status, Tracker, ..
  26. Code Review (5)
  27. To-Do Is name field required? How we can make it optional? We need to force different title for each book?
  28. TBD Realtime Communication What is new in Django 3 Deployment
  29. Thank You

Notas do Editor

  1. 1. It is MVC Framework 2. based on Python — one of the top web development languages 3.  the best of any other open-source framework. And it’s still maintained on a high level 4. Security Is a high priority, and it helps developers avoid common security issues like cross-site scripting,and SQL injection 5. Works with most major databases and even with multiple databases at the same time
  2. 1. How Can I send a welcome email to the user after registration?
  3. 1. How Can I send a welcome email to the user after registration?
  4. Fixtures
  5. Media and static Timezone
  6. Use a solution which integrates well with your version controlling platform. I ended up using CircleCI. CI is especially helpful when you work with multiple developers, since you can be sure their code passes all the tests before they send a pull request. Again, as you can see, it’s very important to have well covered tests in place. Moreover, make sure your master branch is protected.
  7. Active Flag: Staff Flag: Superuser Flag
  8. Active Flag: Staff Flag: Superuser Flag
  9. Active Flag: Staff Flag: Superuser Flag
  10. Active Flag: Staff Flag: Superuser Flag
  11. Question: Hot to get length of an appointment
  12. Question: Hot to get length of an appointment
  13. Ladies first Get exception
  14. Eception will be raised Category.objects.filter(name=name).exists(): mode;.DoesNotExist
  15. Use built in validators
  16. 1. How Can I send a welcome email to the user after registration?
Anúncio