edc-search
Add a slug field to models using the model mixin SearchSlugModelMixin. Specify the fields and/or properties to include in the slug in search_slug_fields:
class TestModel(SearchSlugModelMixin, models.Model):
search_slug_fields = ['f1', 'f2', 'f3']
f1 = models.CharField(max_length=25, null=True)
f2 = models.DateTimeField(null=True)
f3 = models.IntegerField(null=True)
f4 = models.CharField(max_length=25, null=True)
Fields in the search_slug_fields are converted to string in the slug:
>>> obj = TestModel.objects.create(f1='run rabbit run!', f2=get_utcnow(), f3=12345)
>>> obj.slug
'run-rabbit-run!|2017-06-02 19:08:32.163520+00:00|12345'
Fields not listed are not included:
>>> obj = TestModel.objects.create(f1='slug me', f4='don\'t slug me')
>>> obj.slug
'slug-me||'
Null fields are converted to '':
>>> obj = TestModel.objects.create()
>>> obj.slug
'||'
You can use dotted syntax:
class TestModel(SearchSlugModelMixin, models.Model):
search_slug_fields = ['f1', 'name.first', 'name.last']
f1 = models.CharField(max_length=25, null=True)
def name(self):
return FullName(first='Gore', last='Vidal')
>>> obj = TestModel.objects.create()
>>> obj.slug
'|Gore|Vidal'
Metadata
Release files for edc-search 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| edc_search-1.0.1.tar.gz | 28.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| edc_search-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 54.8 kB
Release files / edc_search-1.0.1.tar.gz
| Download URL | edc_search-1.0.1.tar.gz |
|---|---|
| Size | 28.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3dd481222d40d84e252ff1557c0229c28b3924215c5f6c3f10ad0deb901888db
|
|
BLAKE2b-256 checksum How to use checksums |
3fe6ea4cd03fede16376110af448de5cb2c6e21d537a97dae112ce35d5528011
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|
Release files / edc_search-1.0.1-py3-none-any.whl
| Download URL | edc_search-1.0.1-py3-none-any.whl |
|---|---|
| Size | 26.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ac415fd400ff64f57519cc6a3733336d6725e16417f4700486c05e645c21da8a
|
|
BLAKE2b-256 checksum How to use checksums |
dccea10b5c53555fda0f9a6669223ec4d0fc5ee0b1f386b698d41ebbfc9c743a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|