Skip to content

Commit b6d0d74

Browse files
committed
add new django db models example
1 parent 4f2ab09 commit b6d0d74

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

content/pages/examples/django/django-db-models-model.markdown

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,3 +519,32 @@ def wrapped_manager(klass):
519519
super(SiteRelated, self).save(*args, **kwargs)
520520
```
521521

522+
523+
## Example 5 from sorl-thumbnail
524+
[sorl-thumbnail](https://github.com/jazzband/sorl-thumbnail)
525+
is a code library to make it easier to work with thumbnails
526+
in [Django](/django.html) applications. The code for the
527+
project is open source under the
528+
[BSD 3-Clause "New" or "Revised" license](https://github.com/jazzband/sorl-thumbnail/blob/master/LICENSE).
529+
530+
[**sorl-thumbnail / sorl / thumbnail / models.py**](https://github.com/jazzband/sorl-thumbnail/blob/master/sorl/thumbnail/models.py)
531+
532+
```python
533+
# models.py
534+
~~from django.db import models
535+
from django.utils.encoding import python_2_unicode_compatible
536+
537+
from sorl.thumbnail.conf import settings
538+
539+
540+
@python_2_unicode_compatible
541+
~~class KVStore(models.Model):
542+
~~ key = models.CharField(
543+
~~ max_length=200, primary_key=True,
544+
~~ db_column=settings.THUMBNAIL_KEY_DBCOLUMN
545+
~~ )
546+
~~ value = models.TextField()
547+
548+
def __str__(self):
549+
return self.key
550+
```

content/pages/examples/django/django-dispatch-dispatcher-signal.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ The code for the project is available under the
114114
[**viewflow / viewflow / signals.py**](https://github.com/viewflow/viewflow/blob/master/viewflow/signals.py)
115115

116116
```python
117+
# signals.py
117118
~~from django.dispatch import Signal
118119

119120
~~flow_started = Signal(providing_args=["process", "task"])

0 commit comments

Comments
 (0)