This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.utils.timezone import now | |
| from django.db.models import QuerySet | |
| ... | |
| class RepairedQuerySet(QuerySet): | |
| def get(self, *args, **kwargs): | |
| timer = now() | |
| try: | |
| iterator = self.filter(*args, **kwargs)[:2].iterator() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Developer-Relations Activity | |
| Activity on conferences 2021-2024: | |
| 2024 | |
| • XtremePython, online, November 19th, 2024. µDjango, an Asynchronous Microservices Technique with Practical Examples. https://xtremepython.dev/2024/schedule/ | |
| • PyCon FR november 2024 Django FTL: https://pycon.fr/2024/fr/talks/long-talk.html#talk-SMBF7J |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # to https://gist.github.com/castilhera/4d53f6aa2385bff9eab74392ffd99ea6 | |
| # added function word_count_dict_set | |
| import numpy as np | |
| from timeit import timeit | |
| from faker import Faker | |
| import plotly.graph_objects as go | |
| NO_OF_TESTS = 100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| https://gist.github.com/nipunsadvilkar/fec9d2a40f9c83ea7fd97be59261c400 standard Python docstring format | |
| https://realpython.com/documenting-python-code/#docstring-types - about docstrings | |
| https://peps.python.org/pep-0484/#arbitrary-argument-lists-and-default-argument-values - typehints | |
| https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html - napoleon plugin for docstrings | |
| https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_numpy.html - napoleon plugin for docstrings aternative docs | |
| https://numpydoc.readthedocs.io/en/latest/format.html - nympy docstrings format | |
| https://developer.lsst.io/python/numpydoc.html#py-docstring-sections - vera c. rubin observatory suggestions about docstrings | |
| https://www.datacamp.com/tutorial/docstrings-python - generic info about docstrings | |
| PyCharm docstrings generation: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1 $(document).ready(function() { | |
| 2 $(".js-inline-admin-formset").each(function() { | |
| 3 const data = $(this).data(), | |
| 4 inlineOptions = data.inlineFormset; | |
| 5 let selector; | |
| 6 switch(data.inlineType) { | |
| 7 case "stacked": | |
| 8 selector = inlineOptions.name + "-group .inline-related"; | |
| 9 $(selector).stackedFormset(selector, inlineOptions.options); | |
| 10 break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def is_multipart(self, *args, **kwargs): | |
| return super().is_multipart() or self.nested.formset.form().is_multipart() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def save(self, *args, **kwargs): | |
| return super().save(*args, **kwargs) or self.nested.formset.save(*args, **kwargs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def changeform_view(self, request, *args, **kwargs): | |
| self.request = request | |
| return super().changeform_view(request, *args, **kwargs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyForm(StackedInline.form): | |
| def __init__(self, *args, **kwargs): | |
| super(MyForm, self).__init__(*args, **kwargs) | |
| self.instance.form = self | |
| class ProductInline(StackedInline): | |
| # ...... | |
| form = MyForm | |
| def image_inline(self, obj=None, *args, **kwargs): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyForm(StackedInline.form): | |
| def __init__(self, *args, **kwargs): | |
| super(MyForm, self).__init__(*args, **kwargs) | |
| self.instance.form = self | |
| def is_valid(self): | |
| return super().is_valid() and self.nested.formset.is_valid() | |
| @cached_property |
NewerOlder