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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file edc_search-1.0.1.tar.gz.
File metadata
- Download URL: edc_search-1.0.1.tar.gz
- Upload date:
- Size: 28.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3dd481222d40d84e252ff1557c0229c28b3924215c5f6c3f10ad0deb901888db
|
|
| MD5 |
4b87b89c3cdaaaa0fa34a615bcea5703
|
|
| BLAKE2b-256 |
3fe6ea4cd03fede16376110af448de5cb2c6e21d537a97dae112ce35d5528011
|
File details
Details for the file edc_search-1.0.1-py3-none-any.whl.
File metadata
- Download URL: edc_search-1.0.1-py3-none-any.whl
- Upload date:
- Size: 26.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac415fd400ff64f57519cc6a3733336d6725e16417f4700486c05e645c21da8a
|
|
| MD5 |
bdeebaa47aedefccb768be6ede971218
|
|
| BLAKE2b-256 |
dccea10b5c53555fda0f9a6669223ec4d0fc5ee0b1f386b698d41ebbfc9c743a
|