AX3-Mixins-1.0.1
توضیحات
Mixins for use into the AX3 tech stack
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | AX3-Mixins-1.0.1 |
| نام | AX3-Mixins |
| نسخه کتابخانه | 1.0.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Axiacore |
| ایمیل نویسنده | info@axiacore.com |
| آدرس صفحه اصلی | https://github.com/axiacore/ax3-mixins |
| آدرس اینترنتی | https://pypi.org/project/AX3-Mixins/ |
| مجوز | - |
# AX3 mixins
Mixins for use into the AX3 tech stack.
## AjaxRequestMixin
Useful when you need a view only for AJAX queries:
```
from ax3_mixins import mixins
class AjaxView(mixins.AjaxRequestMixin, View):
def post(self, request, *args, **kwargs):
# Only get here if was called by an AJAX request.
...
```
## SlugIdMixin
Allows a view to support smart urls with slug and ids.
At urls use:
```
path('leer/<slug:slugid>/', views.PageDetailView.as_view(), name='page_detail'),
```
At views use:
```
from ax3_mixins import mixins
class PageDetailView(mixins.SlugIdMixin):
template_name = 'app/page_detail.html'
queryset = Page.objects.filter(is_active=True)
```
At models use:
```
def get_absolute_url(self):
return reverse('page_detail', args=[f'{self.slug}-{self.id}'])
```
This mixin will get the object using the id and redirect to the current object
slug if is different from the URL. It will add the `object` to the template context.
نحوه نصب
نصب پکیج whl AX3-Mixins-1.0.1:
pip install AX3-Mixins-1.0.1.whl
نصب پکیج tar.gz AX3-Mixins-1.0.1:
pip install AX3-Mixins-1.0.1.tar.gz