Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[검수] 220211 generic relation import 누락 반영 #58

Open
wants to merge 121 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
a80f68e
first commit
leehosung Sep 3, 2018
aa31e26
update index.rst
leehosung Sep 3, 2018
ac0ccd4
Merge pull request #1 from 8percent/180904-first-test
leehosung Sep 3, 2018
4e96357
테스트 목적으로 업데이트
leehosung Sep 4, 2018
f3738ab
order_by 부분 번역
initialkommit Sep 22, 2018
0ca0b15
union 부분 번역
initialkommit Sep 22, 2018
97cfcda
ADD: 1.one_to_on TO 4.self-referencing
anohk Sep 25, 2018
dfd13d4
CHG: modify syntax
anohk Sep 25, 2018
b62b207
CHG: modify syntax
anohk Sep 25, 2018
2d81868
ADD: 번역 추가
anohk Sep 26, 2018
7dfdeb5
modify syntax
anohk Sep 26, 2018
1a128ec
번역 추가
anohk Sep 26, 2018
be525e5
modify syntax
anohk Sep 26, 2018
bd97ba1
Translate Queryset ordering
Kirade Sep 26, 2018
ed47b2e
Translate rest
Kirade Sep 26, 2018
f684954
Update f_query.rst
hshwang-jdlab Sep 26, 2018
2b10a64
Update filefield.rst
hshwang-jdlab Sep 26, 2018
17439a0
Update join.rst
hshwang-jdlab Sep 26, 2018
33b94e3
Update second_largest.rst
hshwang-jdlab Sep 26, 2018
e9ff7d1
Update distinct.rst
hshwang-jdlab Sep 26, 2018
60c9167
Update duplicate.rst
hshwang-jdlab Sep 26, 2018
824f9b0
annotated field에 code block 깨진 거 처리
initialkommit Sep 27, 2018
4e4b472
code block 사이에 whitespace 추가
initialkommit Sep 27, 2018
6f0814c
code block 처리
initialkommit Sep 27, 2018
7ca4e29
code block 처리
initialkommit Sep 27, 2018
38885dd
code block 처리
initialkommit Sep 27, 2018
7525409
code block 처리
initialkommit Sep 27, 2018
f8d6c5f
Merge pull request #5 from 8percent/tips
bakyeono Sep 29, 2018
fcda676
Merge pull request #2 from 8percent/TRANSLATE-order-by
bakyeono Sep 29, 2018
940e561
Merge pull request #3 from 8percent/relationship
bakyeono Sep 29, 2018
0e018cc
Merge pull request #4 from 8percent/generic_fk
bakyeono Sep 29, 2018
3d53508
Merge branch 'master' into jaeyoung
bakyeono Sep 29, 2018
463ae43
Merge pull request #6 from 8percent/jaeyoung
bakyeono Sep 29, 2018
49efb6b
Merge pull request #7 from hshwang-jdlab/patch-2
bakyeono Sep 29, 2018
4e8a6a2
Merge pull request #8 from 8percent/TRANSLATE-union
bakyeono Sep 29, 2018
ad174b7
README, index
bakyeono Sep 29, 2018
6930675
introduction
bakyeono Sep 29, 2018
13adc11
query
bakyeono Sep 29, 2018
7ec7618
or_query
bakyeono Sep 29, 2018
c73efa3
and_Query
bakyeono Sep 29, 2018
afbdf39
notequal_query
bakyeono Sep 29, 2018
797fac1
union
bakyeono Sep 29, 2018
43e8358
Django ORM cookbook Chapter 2.14 부터 Chapter 2.17까지 번역.
teekey-dev Sep 29, 2018
ffa5099
select_some_fields
bakyeono Sep 29, 2018
ffbb4d1
subquery
bakyeono Sep 29, 2018
4324bd7
subquery
bakyeono Sep 29, 2018
3fa19af
f_query
bakyeono Sep 29, 2018
e28bf1e
filefield
bakyeono Sep 29, 2018
744cd58
join
bakyeono Sep 29, 2018
5ddeabe
second_largest 1
bakyeono Sep 29, 2018
fe1902f
second_largest 1
bakyeono Sep 29, 2018
f9e80c4
Merge pull request #9 from hegrecom/2_14_to_2_17
bakyeono Sep 29, 2018
58c0981
second_largest 2
bakyeono Sep 29, 2018
3baf91f
duplicate
bakyeono Sep 29, 2018
421180a
distinct
bakyeono Sep 29, 2018
c1d4a16
query_relatedtool
bakyeono Sep 29, 2018
0320bc0
aggregation
bakyeono Sep 29, 2018
1cd4c7f
random
bakyeono Sep 29, 2018
d8e2fe6
func_expressions
bakyeono Sep 29, 2018
60a65f8
Merge branch 'master' of github.com:8percent/django-orm-cookbook-ko
bakyeono Sep 29, 2018
74f46ea
2부까지 퇴고
bakyeono Sep 29, 2018
2923068
introduction
bakyeono Sep 29, 2018
6ed7cc8
오타, 문구 수정
bakyeono Sep 29, 2018
d071946
singleton
bakyeono Sep 29, 2018
b2bc04d
truncate
bakyeono Sep 29, 2018
54ea6bc
signals
bakyeono Sep 29, 2018
ca47733
datetime
bakyeono Sep 29, 2018
e0f1601
fix: truncate
bakyeono Sep 29, 2018
bfb034c
join 원어 병기
bakyeono Sep 30, 2018
7c865a7
auto increment 병기
bakyeono Sep 30, 2018
4ee1165
signals
bakyeono Sep 30, 2018
e2e02d2
copy
bakyeono Sep 30, 2018
382bc9a
distinct
bakyeono Sep 30, 2018
7d234ea
관대한 -> 선한
bakyeono Sep 30, 2018
0d66fa4
asc_or_desc
bakyeono Sep 30, 2018
6fcf661
case_insensitive
bakyeono Sep 30, 2018
1332f03
order_by_related_model
bakyeono Sep 30, 2018
db67599
order_by_related_model
bakyeono Sep 30, 2018
c96fb00
order_by_annotated_field
bakyeono Sep 30, 2018
0fbc17d
one_to_one
bakyeono Sep 30, 2018
9bffffc
one_to_one
bakyeono Sep 30, 2018
6b34927
one_to_many
bakyeono Sep 30, 2018
aa38e06
many_to_many
bakyeono Sep 30, 2018
4920031
self_fk
bakyeono Sep 30, 2018
f38ac94
existing_database
bakyeono Sep 30, 2018
a8fc533
database_view
bakyeono Sep 30, 2018
6bfff1a
Merge pull request #10 from 8percent/퇴고-1부-2부
bakyeono Sep 30, 2018
a980114
Merge branch 'master' into 퇴고-4부-5부
bakyeono Sep 30, 2018
de1387b
generic_models
bakyeono Sep 30, 2018
77bcc9f
generic_models
bakyeono Sep 30, 2018
c978b7e
table_names
bakyeono Sep 30, 2018
c4563ad
column_name
bakyeono Sep 30, 2018
aa233f1
index
bakyeono Sep 30, 2018
68eaccb
null_vs_blank
bakyeono Sep 30, 2018
cc1ac24
uuid
bakyeono Sep 30, 2018
0ebbf2b
slugfield
bakyeono Sep 30, 2018
418388f
multiple_databases
bakyeono Sep 30, 2018
75f5652
numqueries
bakyeono Sep 30, 2018
343a026
keepdb
bakyeono Sep 30, 2018
8931c98
refresh_from_db
bakyeono Sep 30, 2018
9f4da3b
Merge pull request #11 from 8percent/퇴고-4부-5부
bakyeono Sep 30, 2018
b025060
Update README.md
bakyeono Sep 30, 2018
a9b86ae
Update query.rst
hshwang-jdlab Sep 30, 2018
f4f6184
Merge pull request #12 from hshwang-jdlab/patch-3
bakyeono Sep 30, 2018
a842e1f
조판 오류 수정 및 2차 퇴고
bakyeono Sep 30, 2018
faaada9
Merge pull request #13 from 8percent/조판오류수정
bakyeono Sep 30, 2018
9a0fdf5
NEW: PDF 빌드 설정 및 스크립트
leehosung Sep 30, 2018
b3d3151
CHG: 공백 없애기
leehosung Oct 1, 2018
14431b9
CHG: 북커버 제외하기
leehosung Oct 1, 2018
7dfb1c6
FIX: typo
leehosung Oct 1, 2018
118f3df
Merge pull request #15 from 8percent/181001_typo
bakyeono Oct 1, 2018
d2aebad
Merge pull request #14 from 8percent/181001_pdf
bakyeono Oct 1, 2018
02bcf00
Syntax highlighting
mingrammer Oct 2, 2018
5819349
Merge pull request #16 from mingrammer/master
leehosung Oct 2, 2018
a4100a5
FIX: typo
9bow Oct 2, 2018
b4fbbe4
FIX: typo
9bow Oct 2, 2018
702b747
Merge pull request #17 from 9bow/master
bakyeono Oct 3, 2018
bf0d941
FIX: typo
lee-seul Oct 6, 2018
dbbb321
깨진 code block 수정
lee-seul Oct 6, 2018
159ade0
Merge pull request #18 from lee-seul/master
bakyeono Oct 7, 2018
e7ef160
ADD: import 누락 추가
kyungjunleeme Feb 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ADD: 번역 추가
anohk committed Sep 26, 2018
commit 2d818686b2248bbe37bc7b9726f544e60cc9b9ab
42 changes: 25 additions & 17 deletions docs/database_view.rst
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
How to add a model for a database view?
어떻게 데이터베이스 뷰에 모델을 추가하는가?
===============================================

A database view is a searchable object in a database that is defined by a query. Though a view doesn’t store data, some refer to a views as “virtual tables,” you can query a view like you can a table. A view can combine data from two or more table, using joins, and also just contain a subset of information. This makes them convenient to abstract, or hide, complicated queries.
| 데이터베이스 뷰는 쿼리로 정의된 데이터베이스에서 검색 가능한 객체입니다.
| 비록 뷰가 데이터를 저장하지는 않지만, 어떤 것들은 "가상 테이블"이라 불리며 테이블처럼 쿼리를 할 수 있습니다.
| 뷰는 조인을 사용해 둘 혹은 그 이상의 테이블에서 데이터를 조합할 수 있으며, 정보의 하위 부분만 포함합니다.
| 이로 인해 복잡한 쿼리를 쉽게 추상화하거나 은닉할 수 있습니다.
In our SqliteStuio we can see 26 tables and no views.
우리의 SqliteStuio에는 26개의 테이블을 볼 수 있고 뷰는 없습니다.

.. image:: before_view.png

Lets create a simple view. ::
간단한 뷰를 만들어봅시다.

create view temp_user as
select id, first_name from auth_user;
.. code-block:: sql
After the view is created, we can see 26 tables and 1 view.
create view temp_user as
select id, first_name
from auth_user;
뷰가 생성된 후, 우리는 26개의 테이블과 1개의 뷰를 확인할 수 있습니다.

.. image:: after_view.png

We can create its related model in our app, by :code:`managed = False` and :code:`db_table="temp_user"` ::
앱에서 ``managed = False`` , ``db_table="temp_user"`` 로 관련 모델을 생성할 수 있습니다.

.. code-block:: python
class TempUser(models.Model):
first_name = models.CharField(max_length=100)
@@ -25,14 +33,14 @@ We can create its related model in our app, by :code:`managed = False` and :code
managed = False
db_table = "temp_user"
// We can query the newly created view similar to what we do for any table.
>>> TempUser.objects.all().values()
<QuerySet [{'first_name': 'Yash', 'id': 1}, {'first_name': 'John', 'id': 2}, {'first_name': 'Ricky', 'id': 3}, {'first_name': 'Sharukh', 'id': 4}, {'first_name': 'Ritesh', 'id': 5}, {'first_name': 'Billy', 'id': 6}, {'first_name': 'Radha', 'id': 7}, {'first_name': 'Raghu', 'id': 9}, {'first_name': 'Rishabh', 'id': 10}, {'first_name': 'John', 'id': 11}, {'first_name': 'Paul', 'id': 12}, {'first_name': 'Johny', 'id': 13}, {'first_name': 'Alien', 'id': 14}]>
// You cannot insert new reord in a view.
>>> TempUser.objects.create(first_name='Radhika', id=15)
Traceback (most recent call last):
...
django.db.utils.OperationalError: cannot modify temp_user because it is a view
>>> # 테이블에 수행하는 것과 유사하게 새로 생성된 뷰에 쿼리를 할 수 있습니다.
>>> TempUser.objects.all().values()
<QuerySet [{'first_name': 'Yash', 'id': 1}, {'first_name': 'John', 'id': 2}, {'first_name': 'Ricky', 'id': 3}, {'first_name': 'Sharukh', 'id': 4}, {'first_name': 'Ritesh', 'id': 5}, {'first_name': 'Billy', 'id': 6}, {'first_name': 'Radha', 'id': 7}, {'first_name': 'Raghu', 'id': 9}, {'first_name': 'Rishabh', 'id': 10}, {'first_name': 'John', 'id': 11}, {'first_name': 'Paul', 'id': 12}, {'first_name': 'Johny', 'id': 13}, {'first_name': 'Alien', 'id': 14}]>
>>> # 뷰에 새로운 레코드를 삽입할 수는 없습니다.
>>> TempUser.objects.create(first_name='Radhika', id=15)
Traceback (most recent call last):
...
django.db.utils.OperationalError: cannot modify temp_user because it is a view

For view having union operation refer to :
union 연산이 있는 뷰는 다음을 참고하세요 :
http://books.agiliq.com/projects/django-admin-cookbook/en/latest/database_view.html?highlight=view
16 changes: 12 additions & 4 deletions docs/existing_database.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
How to convert existing databases to Django models?
이미 존재하는 데이터베이스를 어떻게 장고 모델로 변환하는가?
=====================================================

Django comes with a utility called :code:`inspectdb` that can create models by introspecting an existing database. You can view the output by running this command ::
| Django 에는 존재하는 데이터베이스를 검토하여 모델로 생성할 수 있는 ``inspectdb`` 라는 기능이 있습니다.
| 다음과 같은 명령어로 결과를 확인할 수 있습니다.
::

$ python manage.py inspectdb

Befor running this you will have to configure your database in the :code:`settings.py` file. The result will be a file containing a model for each table. You may want to save that file ::
| 실행하기 전 반드시 ``settings.py`` 파일에 변환하려는 데이터베이스를 정의해야 합니다.
| 결과는 각 테이블의 모델을 담은 파일이 될 것입니다.
다음과 같이 파일을 저장할 수 있습니다.

::

$ python manage.py inspectdb > models.py

The output file will be saved to your current directory. Move that file to the correct app and you have a good starting point for further customizations.
위의 명령으로 결과 파일이 현재 디렉토리에 저장될 것입니다. 해당 파일을 앱의 올바른 위치로 이동시키면 추가적인 커스텀을 시작할 수 있게 됩니다.
48 changes: 21 additions & 27 deletions docs/generic_models.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
How to create a generic model which can be related to any kind of entity? (Eg. a Category or a Comment?)
어떤 종류의 개체와도 연관 지을 수 있는 Generic 모델을 만드는 방법은? (예: 카테고리 또는 코멘트)
=============================================================================================================


You have models like this.
다음과 같은 모델이 있습니다.

.. code-block:: python
@@ -26,9 +25,8 @@ You have models like this.
# ...
:code:`Category` can be applied is a `generic` model. You prbably want to be able to apply categories to objects form any model class.
You can do it like this

| ``Category`` 는 일반적인 모델입니다. 당신은 아마도 여러 모델 클래스 오브젝트에 카테고리를 적용하고 싶을 것입니다.
| 그렇다면 다음과 같이 할 수 있습니다.
.. code-block:: python
@@ -54,41 +52,37 @@ You can do it like this
flex_category = GenericRelation(FlexCategory, related_query_name='flex_category')
# ...
| ``FlexCategory`` 에 ``ForeignKey`` 와 ``PositiveIntegerField`` 를 사용하여 ``GenericForeignKey`` 필드를 적용했습니다.
| 그리고 카테고리를 적용하려는 모델에 ``GenericRelation`` 을 추가했습니다.
|
| 데이터베이스 레벨에서 보면 다음과 같습니다.
What did we do, we added we added a :code:`GenericForeignKey` fields on :code:`FlexCategory` using one :code:`ForeignKey` and one :code:`PositiveIntegerField`, then
added a :code:`GenericRelation` on the models you want to categorize.


At the database level it looks like this:

.. code-block
================== ======================= ====================================================================
Column Type Modifiers
================== ======================= ====================================================================
id integer not null default nextval('entities_flexcategory_id_seq'::regclass)
name character varying(50) not null
object_id integer not null
content_type_id integer not null
================== ======================= ====================================================================

Column | Type | Modifiers
-----------------+-----------------------+--------------------------------------------------------------------
id | integer | not null default nextval('entities_flexcategory_id_seq'::regclass)
name | character varying(50) | not null
object_id | integer | not null
content_type_id | integer | not null
You can categorize a :code:`Hero` like this.
``Hero`` 는 다음과 같이 카테고리를 생성할 수 있습니다.


.. code-block:: python
hero = Hero.objects.create(name='Hades')
FlexCategory.objects.create(content_object=hero, name="mythic")
And then get a :code:`Hero` categorised as 'ghost' like this
'ghost'로 분류된 ``Hero`` 는 다음과 같이 얻을 수 있습니다.

.. code-block:: python
FlexCategory.objects.create(content_object=hero, name="ghost")
Hero.objects.filter(flex_category__name='ghost')
This gives us this sql.
위의 쿼리는 다음과 같은 sql을 만듭니다.

.. code-block:: sql
SELECT "entities_hero"."name"
FROM "entities_hero"
INNER JOIN "entities_flexcategory" ON ("entities_hero"."id" = "entities_flexcategory"."object_id"