Skip to content

Commit

Permalink
Merge pull request #29 from gionniboy/master
Browse files Browse the repository at this point in the history
fix typos/code tag around
  • Loading branch information
shabda committed May 21, 2018
2 parents 350dcb4 + 05f8351 commit a5b9048
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions docs/and_query.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ How to do AND queries in Django ORM?
If you are using :code:`django.contrib.auth`, you will have a table called :code:`auth_user`. It will have fields as :code:`username`, :code:`first_name`, :code:`last_name` and more.


You qould frequnenty need to want to perform AND operation, to find querysets which match multiple criteria.
You would frequently need to want to perform AND operation, to find querysets which match multiple criteria.

Say you want to find users with :code:`firstname` starting with 'R' AND :code:`last_name` starting with 'D'.

Expand Down Expand Up @@ -48,7 +48,7 @@ Alternatively, you can explicitly use the `&` operator on querysets.
last_name__startswith='D'
)
For complete customisibility, you can use the :code:`Q` objects.
For complete customisability, you can use the :code:`Q` objects.

.. code-block:: python
Expand Down
4 changes: 2 additions & 2 deletions docs/duplicate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Find rows which have duplicate field values

.. image:: usertable2.png

Say you want all users whose :code:`first_name` matchges another user.
Say you want all users whose :code:`first_name` matches another user.

You can find duplicate records using the technique below.

Expand All @@ -15,7 +15,7 @@ You can find duplicate records using the technique below.
>>> duplicates
<QuerySet [{'first_name': 'John', 'name_count': 3}]>
If you need to fil all the records, you can do
If you need to fill all the records, you can do

.. code-block:: python
Expand Down
2 changes: 1 addition & 1 deletion docs/f_query.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ How to filter a queryset with criteria based on comparing their field values
==============================================================================

Django ORM makes it easy to filter based on fixed values.
To get all :code:`User` objects with :code:`first_name` starting with :code`'R'`,
To get all :code:`User` objects with :code:`first_name` starting with :code:`'R'`,
you can do :code:`User.objects.filter(name_startswith='R')`.

What if you want to compare the first_name and last name?
Expand Down
2 changes: 1 addition & 1 deletion docs/notequal_query.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The query in detail
-----------------------


Our SQL query for the above condition will look somethng like ::
Our SQL query for the above condition will look something like ::

SELECT id, username, first_name, last_name, email FROM auth_user WHERE NOT id < 5;

Expand Down
4 changes: 2 additions & 2 deletions docs/query_relatedtool.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
How to use :code:`Q` objects for complex queries?
==================================================

In previous chapters we used :code:`Q` objects for :code:`OR` and :code:`AND` and :code:`NOT ` operations. :code:`Q` objects provides you complete control over the where clause of the query.
In previous chapters we used :code:`Q` objects for :code:`OR` and :code:`AND` and :code:`NOT` operations. :code:`Q` objects provides you complete control over the where clause of the query.

If you want to :code:OR your conditions.
If you want to :code:`OR` your conditions.

.. code-block:: ipython
Expand Down
6 changes: 3 additions & 3 deletions docs/random.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ Your :code:`category` models is like this.
You want to get a random Category. We will look at few alternate ways to do this.

The most straightforward way, you can order_by random and fetch the first record. It would look something like this.
The most straightforward way, you can :code:`order_by` random and fetch the first record. It would look something like this.

.. code-block:: python
def get_random():
return Category.objects.order_by("?").first()
Note: :code:`order_by('?')` queries may be expensive and slow, depending on the database backend you’re using. To test other methods, we need to instert one million records in :code:`Category` table. Go to your db like with :code:`python manage.py dbshell` and run this.
Note: :code:`order_by('?')` queries may be expensive and slow, depending on the database backend you’re using. To test other methods, we need to insert one million records in :code:`Category` table. Go to your db like with :code:`python manage.py dbshell` and run this.

.. code-block:: sql
Expand Down Expand Up @@ -58,7 +58,7 @@ generate a random number in range [1, max_id], and filter that. You are assuming
In [6]: get_random2()
Out[6]: <Category: f164ad0c5bc8300b469d1c428a514cc1>
If your models has deletions, you can sligthtly modify the functions, to loop until you get a valid :code:`Category`.
If your models has deletions, you can slightly modify the functions, to loop until you get a valid :code:`Category`.

.. code-block:: python
Expand Down
4 changes: 2 additions & 2 deletions docs/subquery.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
How to do a subquery experession in Django?
How to do a subquery expression in Django?
=============================================

Django allows using SQL subqueries.
Expand Down Expand Up @@ -32,7 +32,7 @@ The models look something like this.
)
You can find the most benevolvent Hero like this
You can find the most benevolent Hero like this

.. code-block:: python
Expand Down
2 changes: 1 addition & 1 deletion docs/union.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ How to do union of two querysets from same or different models?
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

The UNION operator is used to combine the result-set of two or more querysets.
The querysets can be from the same or from different models. When they querysets are from different models, the fields and their datatypes shoudl match.
The querysets can be from the same or from different models. When they querysets are from different models, the fields and their datatypes should match.

Let's continue with our :code:`auth_user` model and generate 2 querysets to perform union operation

Expand Down

0 comments on commit a5b9048

Please sign in to comment.