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
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) )
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.
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.
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"))
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"))
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)()
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
1. How Can I send a welcome email to the user after registration?
1. How Can I send a welcome email to the user after registration?
Fixtures
Media and staticTimezone
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.
Active Flag: Staff Flag: Superuser Flag
Active Flag: Staff Flag: Superuser Flag
Active Flag: Staff Flag: Superuser Flag
Active Flag: Staff Flag: Superuser Flag
Question: Hot to get length of an appointment
Question: Hot to get length of an appointment
Ladies first
Get exception
Eception will be raised
Category.objects.filter(name=name).exists():mode;.DoesNotExist
Use built in validators
1. How Can I send a welcome email to the user after registration?