Simple edc-search forms and view mixins for the clinicedc/edc
Project description
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'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
edc-search-0.3.11.tar.gz
(28.1 kB
view details)
Built Distribution
File details
Details for the file edc-search-0.3.11.tar.gz
.
File metadata
- Download URL: edc-search-0.3.11.tar.gz
- Upload date:
- Size: 28.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4ee4fc3f6c234c0fa31fd2ee579adb128306d9c78d101977a73ea5631ec9682 |
|
MD5 | 4076eec4329909b4968c71d91b844edd |
|
BLAKE2b-256 | 8712b8f42d8117633001ea818b73960c1c648f5f34ca7d46a937acb319f5d967 |
File details
Details for the file edc_search-0.3.11-py3-none-any.whl
.
File metadata
- Download URL: edc_search-0.3.11-py3-none-any.whl
- Upload date:
- Size: 25.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08386e4e56556b665f7f66bdf8c60c9371cdd4005df4fec80bebe06596b90557 |
|
MD5 | fa58f2dbaccb0d0cb1d410ccdbed0863 |
|
BLAKE2b-256 | 33f34895a2572b25b456996bef0e88adf6dcbd3926202deef13b10659fe55bb4 |