Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django2-project-template
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django2-project-template
Commits
34888592
Unverified
Kaydet (Commit)
34888592
authored
Mar 22, 2019
tarafından
Uğur Özyılmazel
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix generator templates
üst
18b7367e
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
8 additions
and
35 deletions
+8
-35
README.md
README.md
+5
-30
Rakefile
Rakefile
+1
-1
create_model.py
applications/baseapp/management/commands/create_model.py
+2
-1
basemodel.py
...aseapp/management/template_structures/admins/basemodel.py
+0
-1
django.py
...s/baseapp/management/template_structures/admins/django.py
+0
-1
softdelete.py
...seapp/management/template_structures/admins/softdelete.py
+0
-1
No files found.
README.md
Dosyayı görüntüle @
34888592
...
...
@@ -92,7 +92,6 @@ You can fix your Django Admin titles now. Go to `config/urls.py` and fix:
admin
.
site
.
index_title
=
_
(
'Your admin index title'
)
admin
.
site
.
site_title
=
_
(
'Your site title'
)
admin
.
site
.
site_header
=
_
(
'Your site header'
)
```
Do not forget to compile your locale messages files.
...
...
@@ -150,7 +149,6 @@ $ rake new:application[blog]
# ..
]
# ...
```
Fix your
`config/settings/base.py`
, add this newly created app to your
`INSTALLED_APPS`
:
...
...
@@ -164,7 +162,6 @@ AUTH_USER_MODEL = 'baseapp.User'
INSTALLED_APPS
+=
[
'blog.apps.BlogConfig'
,
]
```
Now, if you fix your
`config/urls.py`
you’ll be able to see demo
...
...
@@ -216,7 +213,6 @@ class BlogView(HtmlDebugMixin, TemplateView):
kwargs
=
super
()
.
get_context_data
(
**
kwargs
)
console
.
dir
(
self
.
request
.
user
)
return
kwargs
```
Let’s look at our
`blog`
application structure:
...
...
@@ -259,7 +255,6 @@ Post model added to admin/__init__.py
-
`
blog/admin/post.py
`
Please check your models before running
`
makemigrations
`
ok?
```
This creates
`blog/models/post.py`
and
`blog/admin/post.py`
files:
...
...
@@ -287,12 +282,10 @@ class Post(BaseModelWithSoftDelete):
class
Meta
:
app_label
=
'blog'
verbose_name
=
_
(
'post'
)
verbose_name_plural
=
_
(
'post'
)
verbose_name_plural
=
_
(
'post
s
'
)
def
__str__
(
self
):
return
self
.
title
```
and
`Category`
model:
...
...
@@ -316,7 +309,6 @@ Category model added to admin/__init__.py
-
`
blog/admin/category.py
`
Please check your models before running
`
makemigrations
`
ok?
```
Now It’s time to fix our models by hand!
...
...
@@ -352,13 +344,8 @@ class Post(BaseModelWithSoftDelete):
related_name
=
'posts'
,
verbose_name
=
_
(
'category'
),
)
title
=
models
.
CharField
(
max_length
=
255
,
verbose_name
=
_
(
'title'
),
)
body
=
models
.
TextField
(
verbose_name
=
_
(
'body'
),
)
title
=
models
.
CharField
(
max_length
=
255
,
verbose_name
=
_
(
'title'
))
body
=
models
.
TextField
(
verbose_name
=
_
(
'body'
))
class
Meta
:
app_label
=
'blog'
...
...
@@ -367,7 +354,6 @@ class Post(BaseModelWithSoftDelete):
def
__str__
(
self
):
return
self
.
title
```
We’ll keep
`blog/models/category.py`
same,
`Category`
will have only
`title`
...
...
@@ -391,19 +377,15 @@ console = console(source=__name__)
class
Category
(
BaseModelWithSoftDelete
):
title
=
models
.
CharField
(
max_length
=
255
,
verbose_name
=
_
(
'title'
),
)
title
=
models
.
CharField
(
max_length
=
255
,
verbose_name
=
_
(
'title'
))
class
Meta
:
app_label
=
'blog'
verbose_name
=
_
(
'category'
)
verbose_name_plural
=
_
(
'categories'
)
def
__str__
(
self
):
return
self
.
title
```
...
...
@@ -848,7 +830,6 @@ SELECT "blog_category"."id",
>>>
Category
.
objects
.
deleted
()
<
BaseModelWithSoftDeleteQuerySet
[
<
Category
:
Python
>
]
>
```
`BaseModelWithSoftDeleteQuerySet`
has these query options according to
...
...
@@ -899,7 +880,6 @@ class PostAdmin(BaseAdminWithSoftDelete):
# sticky_list_filter = None
# hide_deleted_at = False
pass
```
By default,
`deleted_at`
excluded from admin form like
`created_at`
and
...
...
@@ -978,7 +958,6 @@ class IndexView(HtmlDebugMixin, TemplateView):
self
.
hdbg
(
'self.hdbg'
,
'usage'
)
self
.
hdbg
(
self
.
request
.
__dict__
)
return
kwargs
```
`{% hdbg %}`
tag added by default in to your
`templates/base.html`
:
...
...
@@ -1169,7 +1148,6 @@ class MyModel(models.Model):
upload_to
=
'my_custom_uploader'
,
verbose_name
=
_
(
'Profile Image'
),
)
```
## `AdminImageFileWidget`
...
...
@@ -1183,7 +1161,6 @@ class MyAdmin(admin.ModelAdmin):
formfield_overrides
=
{
models
.
FileField
:
{
'widget'
:
AdminImageFileWidget
},
}
```
This widget uses
`Pillow`
(
*Python Image Library*
) which ships with your
`base.pip`
...
...
@@ -1239,7 +1216,6 @@ can customize look and feel here:
}
</style>
{%
endblock
%}
```
This adds a basic HTML element via CSS to the
`<body>`
tag.
...
...
@@ -1467,7 +1443,6 @@ class Page(models.Model):
# YOUR_APP/models/__init__.py
# append:
from .page import
*
```
Now make migrations etc... Use it as
`from YOUR_APP.models import Page`
:)
...
...
Rakefile
Dosyayı görüntüle @
34888592
...
...
@@ -33,7 +33,7 @@ namespace :new do
AVAILABLE_MODEL_TYPES
=
[
'django'
,
'basemodel'
,
'softdelete'
]
desc
"Create new Model for given application"
desc
"Create new Model for given application
:
#{
AVAILABLE_MODEL_TYPES
.
join
(
','
)
}
"
task
:model
,
[
:name_of_application
,
:name_of_model
,
:type_of_model
]
=>
[
:check_development_environment
]
do
|
t
,
args
|
args
.
with_defaults
(
:type_of_model
=>
"django"
)
abort
"Please provide: 'name_of_application'"
unless
args
.
name_of_application
...
...
applications/baseapp/management/commands/create_model.py
Dosyayı görüntüle @
34888592
...
...
@@ -64,7 +64,8 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
app_name
=
options
.
pop
(
'app_name'
)[
0
]
model_name
=
options
.
pop
(
'model_name'
)[
0
]
model_name
=
options
.
pop
(
'model_name'
)[
0
]
.
lower
()
model_name_title
=
model_name
.
title
()
model_type
=
options
.
pop
(
'model_type'
)
...
...
applications/baseapp/management/template_structures/admins/basemodel.py
Dosyayı görüntüle @
34888592
...
...
@@ -7,7 +7,6 @@ from baseapp.utils import console
from ..models import {model_name_title}
__all__ = ['{model_name_title}Admin']
logger = logging.getLogger('app')
...
...
applications/baseapp/management/template_structures/admins/django.py
Dosyayı görüntüle @
34888592
...
...
@@ -6,7 +6,6 @@ from baseapp.utils import console
from ..models import {model_name_title}
__all__ = ['{model_name_title}Admin']
logger = logging.getLogger('app')
...
...
applications/baseapp/management/template_structures/admins/softdelete.py
Dosyayı görüntüle @
34888592
...
...
@@ -7,7 +7,6 @@ from baseapp.utils import console
from ..models import {model_name_title}
__all__ = ['{model_name_title}Admin']
logger = logging.getLogger('app')
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment