Saravanan666/pypi-org huggingface dataset:
Package: django-viewedmodels
ViewedModelsViewed Models is a simple way to add PostGres “views” which look to Django just like Models.
This lets us go outside the Django ORM to create views or materialized views to harness
the power of PostGreSQL without losing the power to access that data using the ORM. It is
very probably compatible with other DBMS but tested only with PG.InstallationFor production:pip install django-viewedmodelsFor development:pip install -e git+https://github.com/joshbrooks/django_viewedmodels#egg=viewedmodelsUsageA model which uses this framework should inherit from ViewedModelThe model requires an “sql” method which returns the sql required to create viewThe model also requires a “dependencies” attribute. These are useful in generating table names within the SQL statement as well as dependency resolution.The model also requires fields specified in the standard Django way. Foreign keys should work fine.Foreign Keys: ForForeignKey(myApp.MyModel')we need to have a fieldmymodel_idreturned from the SQL.Every Django model (including these ViewedModels) requires an ‘id’ field. We can fake this by includingrow_number() OVER () AS idsomewhere (usually as the first item) in our SELECT statement.Examplefrom django.db import models
from django.contrib.postgres.fields import JSONField
from viewedmodels.models import ViewedModel
from viewedmodels.helpers import dependency_lookup


class ActivityCommitment(ViewedModel):
    # Declaring dependencies for table lookup in the query and orderly build/ teardown of the views structure if
    # there is inheritance between ViewedModel instances
    dependencies = (
        ('aims', 'Activity'),
        ('aims', 'AidTypeCategory'),
        ('iati', 'Transaction'),
        ('aims', 'AidType'),
        ('aims', 'TransactionValueUSD')
    )

    @classmethod
    def sql(cls):
        tables = dependency_lookup(
            cls.dependencies)  # This returns a lookup for 'app_model' string to the true table name
        return '''
        SELECT
            -- Columns { id, activity_id, aidtypecategory_id, dollars } reflect our field definition for the model
            ROW_NUMBER() OVER () id, --Note how an id field is autogenerated for Django's sake
            {aims_activity}.remote_data_id activity_id, -- This will be used as a ForeignKeyField, Django requires _id by default
            {aims_aidtypecategory}.code aidtypecategory_id, -- Another fk field
            {aims_transactionvalueusd}.dollars dollars
        FROM
            {aims_activity},
            {aims_transactionvalueusd},
            {iati_transaction},
            {aims_aidtype},
            {aims_aidtypecategory}
        WHERE
            --... --truncated for brevity
    '''.format(**tables)

    # id = models.AutoField(primary_key=True)
    activity = models.ForeignKey('aims.Activity')  # Represented as 'activity_id' in the query above
    aidtypecategory = models.ForeignKey(
        'aims.AidTypeCategory')  # Represented as 'aidtypecategory_id' in the query above
    dollars = models.FloatField()
Package: django-viewers-counts-middleware
Django Viewers Count MiddlewareViewers Count is a Django app to collect visitors request counts with path.Detailed documentation.Quick startAdd "viewers_count" to your INSTALLED_APPS setting like this::INSTALLED_APPS = [...
 'viewers_count',]Add "ViewerCountMiddleware" to your INSTALLED_APPS setting like this::MIDDLEWARE = [...
 'viewers_count.middleware.ViewersCountMiddleware',]Run to create the viewerscount models.python manage.py migrate
Package: django-view-export
Generate CSV reports by simply creating SQL views.Authenticated staff members can then directly download these reports as CSV.
It’s a nice agile way to deal with the changing requirements for reports.Quick startInclude the URLconf in your projecturls.pylike this:path('reports/',include('view_export.urls')),Create an SQL view in your database:=>CREATEVIEWv_staff_namesAS(->SELECTfirst_name,last_nameFROMauth_user->WHEREis_staff=TRUE);You’ll probably want to record this SQL in a file such asreports.sqlor
even better, add it to a Django migration.Start the development server and visithttp://127.0.0.1:8000/reports/staff_names/orhttp://127.0.0.1:8000/reports/v_staff_names/to download the SQL view namedv_staffas a CSV file.No settings are required by default and there’s no need to add the package to
Django’sINSTALLED_APPS. Staff login access is required, so you may wish to
set theLOGIN_URLsetting to/admin/login/initially.Release History1.0.0 (2021-09-28)Upgrade for Python 3.6 and Django 3.2.0.7.1 (2017-02-07)RemovepatternsURLconf function per deprecation in Django 1.8.Fix example URLs in README.Provide example view with underscores.Document staff-only access and LOGIN_URL setting.0.6.2 (2015-09-04)BugfixesFix installation error due to HISTORY.rst not being present in source.0.6.1 (2015-08-25)ImprovementsSwitch to Python 3 only, factor out CSV and report filename generation.0.5.5 (2015-08-25)BugfixesFix installation error due to HISTORY.rst not being present in source.0.5.4 (2015-08-09)BugfixesFix SQL injection vulnerability relating to “view” argument.0.5.3 (2015-08-05)ImprovementsUpdate documentation.Rename PyPI package todjango-view-export.
Package: django-viewmodels
django-viewmodels=================Automatic viewmodel conversion for django class-based views* import View from djviewmodels.views and use it as a base class** define viewmodels as a dictionary (key: variable name in context, value: class to replace with)for automatic conversion of variables in the returned context to viewmodels** define get, post, put, delete as methods to handle those requests, return a context dictionary** define init_request as a generic method to handle the beginning of all requests*** init_request can return a dictionary, whose values will be passed to get/post/whoever*** init_request returned dictionary will be added to template context** define template_name or json*** template_name will cause context dictionaries to be rendered to that template*** json will cause context dictionaries to be rendered to json* Automatic viewmodel extension of models:** define wrap_each to have individual viewmodels wrapped around individual models*** __getattr__ will look inside the instance for fields*** define fields to specify which fields to allow automatic retrieval of*** define exclude to exclude fields** define wrap_collection to have the viewmodel wrap around the whole list* deprecated receive_single_instance and receive_multiple_instances still functional until v1.0* viewmodel replacement function and decorator can be used in viewmodels or views without the class based view of django viewmodels:** djviewmodels.utils.vm_replace(cls, obj_or_list, request=None) accepts a viewmodel class, an object or list, and an optional request, and returns viewmodels** djviewmodels.decorators.viewmodel_wrap(cls) wraps a function that returns some value and turns that value into cls-based viewmodels. Looks for self.request on methods.See the tests for more information and usage
Package: django-view-models
django_view_modelsDesigned for Postgres. May or may not work with other databases.Installation/Usagepip install django_view_modelsadddjango_view_modelstoINSTALLED_APPSdefine view models (see below)python manage.py sync_view_models(run after every view definition change)Defining View ModelsYou must define the fields on your model, and either defineVIEW_DEFINITIONorview_queryon your model.Note that just like regular models, django will add an integer primary key calledid, unless you setprimary_key=Trueon one of your fields.fromdjango.dbimportmodelsfromdjango_view_models.modelsimportViewModel,MaterializedViewModelclassBook(models.Model):title=models.TextField()is_good=models.BooleanField()# create a ViewModel with a manual queryclassGoodBook(ViewModel):title=models.TextField()VIEW_DEFINITION='''SELECT id, titleFROM my_app.bookWHERE is_good = true'''# create a ViewModel, and use Django's ORM to create the queryclassBadBook(ViewModel):title=models.TextField()defview_query():returnBook.objects.filter(is_good=False).values('id','title')
Package: django-viewpack
Django’s class based generic views are a great way to reuse code and avoid
boilerplate. In Django, however, each view is associated with a single URL. If
you want to reuse some behavior that involves multiple urls it is often
necessary to synchronize many different views. Think about a CRUD interface: it
is not necessarily hard, but it can be both tedious and error prone.View packs gather a collection of views and url entry points together in a single
reusable unity. Hence, instead of creating separate CreateView, DetailView,
UpdateView, DeleteView, etc, we can simply subclass the CRUDViewPack view pack:from viewpack import CRUDViewPack
from fooapp.models import FooModel


class FooCRUD(CRUDViewPack):
    model = FooModelIn your urls.py, register all CRUD views as an include:from django.conf import url
from views import FooCRUD


urlpatterns = [
    ...,
    url(r'^foo/', FooCRUD.as_include(namespace='foo')),
]Now you have registered a simple CRUD interface for yourFooModel. The next
step is to write the required templates and you’re done! (In fact, if you are
lazy and use Jinja, we even offer a few ready to use templates!)
Package: django-viewpass
ViewpassOverviewThis is a system for allowing the creation and use of URLs that contain a token that allows
a site visitor, even an anonymous visitor, access to pages that might not normally be allowed
to visit.For example, say you have a report page at/report/that normally requires the permission
‘reporting.view_report’ to view. However, you’d like to be able to send emails to some friends
to allow them to view this page without needing an account.Viewpass is:a utility to craft URLs with embedded, cryptographically-signed information about a
permissiona Django middleware that intercepts URLs with these kind of URLs, and stores information
about that permission onto the user object.InstallingAdd ‘viewpass’ to theINSTALLED_APPS:INSTALLED_APPS = [
    # ...
    'viewpass',
]Add it to the middleware classes: This need to be after the Authentication Middleware (since
we need a user!). A good arrangement could be:MIDDLEWARE_CLASSES = [
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'viewpass.middleware.ViewPassMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]Add viewpass to theAUTHENTICATION_BACKENDS:AUTHENTICATION_BACKENDS = [
    'viewpass.backends.ViewPassBackend',
    'django.contrib.auth.backends.ModelBackend'
]Generating Viewpass URLsYou can generate the proper URL for them by using the methodutil.get_viewpass_url, like:get_viewpass_url('/report/', 'reporting.view_report')This URL will look like/report/?viewpass=STRING1:STRING2and visitors can use this URL to
visit the/report/page.The STRING1 and STRING2 are encoded versions of the timestamp/path/permission-to-grant and a
signed copy of the path/permission-to-grant, respectively. This prevents any tampering by users
trying to re-use a viewpass URL to view another page or to change the permission granted.
(The timestamp is not used but can be used to create time-limited URLs; you can edit thesigning.loads()call inviewpass.middleware.ViewPassMiddlewareto add amax_age=<num_seconds>parameter).As a convenience, you can also use the template tag to generate the proper URL. On the template
that is used by/report/, you can include:{% load viewpass_tags %}
<a href="{% viewpass_url 'reporting.view_report' %}">Get public URL</a>This will show a link with the viewpass URL on it.CreditViewpass is written and maintained by Joel Burton <joel@joelburton.com>.
Package: django-view-permissions
django-view-permissions provides ways to control access for Django app viewsOverviewChecks the incoming requests, to grant or deny access for views accoding to
the permissions defined in the views. If permissions attribute is not defined
in the view, normal django flow is followed. If permissions attribute is
defined in view it checks and grants or denys access of the view.InstallationInstall the latest release using pypi:pip3 install django-view-permissionsAdd the application to the INSTALLED_APPS:INSTALLED_APPS = (
    ...
    # DjangoViewPermissions
    'django_view_permissions',
)Add the middleware to the configuration:MIDDLEWARE_CLASSES = (
    ...
    'django_view_permissions.middleware.DjangoViewPermissionsMiddleware',
)UsageCurrently, 3 ways to define permissions are supported.Attribute based permissionsMethod based permissionsClass based permissionsBelow is a Attribute based permission example. Where view will be only accessable
to users whose attribute ‘is_staff’ is ‘True’.class DummyView(View):
    permissions = [
        ('attr', 'is_staff', True),
    ]In Method based permissions, you will need to defind the method with a ‘request=None’
argument and a boolean return statement. All the requests for which method returns
‘True’ will be able to access the view.class DummyView(View):
    permissions = [
        ('method', permission_method),
    ]In Class based permissions, you will need to defind a class with a ‘request=None’
argument in __init__ method. All the requests for which __call__ method returns
‘True’ will be able to access the view.class DummyView(View):
    permissions = [
        ('class', PermissionClass),
    ]Note: It is recommended to define the permission methods or classes in a separate file.Please checkpermissions.pyfor examples.LicenseThe code in this repository is licensed under the Apache Software License 2.0 unless
otherwise noted.Please seeLICENSEfor details.How To ContributeContributions are very welcome.Please readHow To Contributefor details.Reporting Security IssuesPlease do not report security issues in public. Please emailmuhammadayubkhan6@gmail.com.Getting HelpFeel free to create git issues in case of queries/issues/enhancements.Change LogUnreleasedAdded_[0.0.2] - 19-03-2020AddedFix some documention and release issues.[0.0.1] - 19-03-2020AddedAutomatic upload to PyPI on tags.Documentation[0.0.dev0] - 17-03-2020AddedAttr based permissionsMethod based permissionsClass based permissionsFirst release on PyPI.
Package: django-view-perms
Automatically create and check dedicated permissions for all Django viewsThis Django app can create a dedicated permission for any or all
views in a given app, manage their lifecycle (exclude some views,
remove them all or remove the ones that no longer have an associated
view) and also enforce the created permissions for the logged-in
user. Users will only be able to process the views that they have
been explicitly given the related permission to.After addingview_permsto theINSTALLED_APPSlist, use thecreate_view_permsDjango management command to create all target
permissions automatically. Permissions need to be created before
being enforced. See the command help message for details about
supported options.To automatically enforce the created view permissions, addview_perms.middleware.check_view_perms.ViewPermissionMiddlewareto theMIDDLEWARElist in Django settings. Make sure to put this
middleware afterdjango.contrib.auth.middleware.AuthenticationMiddleware.It is possible to put some views in an ignore list, which results in them
not having the permission created or enforced. This makes sense for parts of
the application like authentication views (user needssomeway to
authenticate, after all), or for public-facing parts of the application.
To do so add the fully qualified view name inVIEW_PERMS_IGNORE_LISTlist in the Django settings module. This app enforces the views
on a per-app basis and does not enforce view permissions for views
that do not have a permission to their name (it’s permissive by
default). So it’s possible to have apps that none of their views are
permission enforced.Names of permissions that this app created (ones which are displayed
in Django admin interface) are composed of a fixed prefix (view_perm_)
and the fully qualified view name (module name +.+ view function or
class name). If these names are too cryptic for users of the admin
interface or you want them to be in a local language, it has been made
possible for the programmer to provide a translation for this string by
assigning the propergettexttranslation to the__name_trans__attribute of the view function or class.
Package: django-views-breadcrumbs
To enabledjango-views-breadcrumbsyou need addviews_breadcrumbstoINSTALLED_APPS:INSTALLED_APPS += ('views_breadcrumbs',)To add breadcrumb to view, usebreadcrumbdecorator:from views_breadcrumbs.views import breadcrumb
...
@breadcrumb('index')
class IndexView(View):
    ...

@breadcrumb(lambda args, kwargs, context, request: context['category'].name, parent='project.views.index')
class ProductListView(ListView):
    ...whereproject.views.indexis view name of parent view.If you want to passobject(first) function parameters to parent, you should useparent_args.
When you passparent_args, parent view will be not dispatched:@breadcrumb(lambda args, kwargs, context, request: context['product'].name,
            parent='project.views.product-list',
            parent_args=lambda args, kwargs, context, request: [], {}, {'category': context['product'].category}
           )
class ProductDetailView(DetailView):
    ...parent_argsmust return list of args, kwargs and context, witch will pass to parent breadcrumbobjectparameterSettingsSetBREADCRUMBS_TEMPLATE_CONTEXT_NAMEto change context name (default isbreadcrumbs):BREADCRUMBS_TEMPLATE_CONTEXT_NAME = 'breadcrumbs'MiddlewareIf you want to get warnings when middle view of breadcrumbs branch is dispatched
(it means dispatched not only current view, but also parent), you can useBreadcrumbsWarningMiddleware:MIDDLEWARE_CLASSES += ('views_breadcrumbs.middleware.BreadcrumbsWarningMiddleware', )
Package: django-viewssi
BugsA template tag for making simulated GET requests to Django application view
functions. The HTTP response can be displayed in the given template.Variations of usage ofviewssi:{% viewssi path.to.view %}
{% viewssi path.to.view arg,arg2,kwarg=val %}
{% viewssi path.to.view arg,arg2,kwarg=val as var %}
{% viewssi path.to.view arg,arg2,kwarg=val get p1=v1,p2=v2 as var %}The first argument is the path to a view function to call. If the
view requiresargsand/orkwargs, pass them as the second
token in the tag.argsand the values ofkwargsare
resolved to template variables unless they are quoted.The view doesn’t have to be exposed in a URL
configuration. Essentially any function can be called that accepts
one argument (the request) and returns adjango.http.HttpResponseobject.You can pass a GET query string by including agettoken in
the tag followed bykey=valuepairs. Parameter values are also
resolved to template variables unless they are quoted.If theas<template-variable-nametoken of the tag is
provided, the view’s response is assigned to the given template
variable. Otherwise, the response content is returned in place.When the response is assigned to a template variable, the http
response is represented as aHttpResponseProxyobject which
contains a template-useable interface for fetching the response
code, headers, and content. Examples:{% ifequal response.status_code "200" %}
{{ response }}
{% endifequal %}HttpResponseProxybehaves is a dict-like object. The http
response headers are set as the dict items and their names are
transposed for use in templates, i.e. ‘Content-type’ becomes
‘content_type’. For example:{% ifequal response.content_type "text/html" %}
{% endifequal %}
Package: django-view-table
django-view-tablePlugin to create view table in Django.This plugin enable you to create view table in Django model.Support DatabaseSQLite3PostgreSQLMySQL(TBC)Oracle DatabaseInstallation & Setuppip install django-view-tableAfter install, you can set yourINSTALLED_APPSINSTALLED_APPS=['viewtable',]UsageCreate modelYou need the three step.Importview_tablemoduleInheritViewTableImplimentget_querymethodThe methodget_queryshould return select sql statement.You can write sql statement as raw sql or django model object.This is a simple example.fromdjango.dbimportmodelsfromview_table.modelsimportViewTable# Base tableclassBook(models.Model):name=models.CharField(max_length=100)category=models.CharField(max_length=100)# View tableclassBooks(ViewTable):category=models.CharField(max_length=100)count=models.IntegerField()# You must implement get_query method.@classmethoddefget_query(self):returnBook.objects.values('category').annotate(count=models.Count('category')).query# You can also write:# return 'SELECT "polls_book"."category", COUNT("polls_book"."category") AS "count" FROM "polls_book" GROUP BY "polls_book"."category"'Run commandAfter Django migration, you can create view tables the below command.pythonmanage.pycreateviewtableDevelopmentI prepare application for this plugin application.https://github.com/pyohei/django-view-tableLicenseMIT
Package: django-viewtester
Table of ContentsWhat is it?RequirementsCreditsHow to get it?UsageOverviewWhat is it?A django-application to automate creating tests for views.Requirementsdjango-1.1jquery1.4+ (optional though advisable).It is assumed jquery is already loaded in your template(s). If not add
this line in the (extra)head-section:<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>CreditsBased on ideas and code from Eric Holscher’s testmaker intest-utils.How to get it?You can download compressed archives frombitbucketor clone the
repository using mercurial. I hope to make it available viaPYPIsometime soon.UsageAdd viewtester to your INSTALLED_APPS and include it in your urls.py
then run:$./manage.py run_viewtester [-f fixture.xml] appnamethen open your browser and go tohttp://localhost:8000/.Click around and see the results in the generated test-file. If all
goes well you should be able to run the resulting tests without any
further ado:$./manage.py test appnameNoteThe __init__.py that comes with viewtester imports all
TestCase classes from all modules in the tests-directory. It is
only created if the tests-dir doesn’t exist when run_viewtester is
started.OverviewOnce added to a project’s settings and urls.py you can use the
run_viewtester command to run the testserver with an app-name as an
argument and optionally a (set of) fixture to populate the
database. This follows the pattern of a djangoTestCase.The command injects middleware that logs all requests to the specified
app and resulting response status’ to a test-module formated as django
TestCases. Tests will be saved to appname/tests/YYYYMMDD-NN.py. You
can override this on the commandline using the -l flag.The middleware will also track any logging in or out you’ll do and
have the test-client log in or out accordingly in the tests.An html-div, the ‘panel’, is injected into the response content that
contains information about the currentTestCase: Classname and loaded
fixtures, current test-method-name and user. You can collapse the div
by clicking on the title and it can be dragged to a non-intrusive
place thanks to the magic ofjquery-ui. It will remember where you
dragged it too.The panel contains a number of forms that allow you to:Create a new Class, optionally with a set of fixtures that it will
also be loaded upon submit. The fixtures can be picked from a
pre-populated multiselect control which contains all the files in
appname/fixtures.Start a new test-method which will also reset the database to the
state it will be when the resulting tests are run: It will be
flushed and the class’ fixtures are loaded.Check the template context-variables by saving assertEqual
statements into the tests by selecting variable-names from a
multi-select control.Save the current database-state for the specified app to a fixture
to use in later tests. Fixtures will be saved to appname/fixtures/
using the name provided. The fixture name should follow the
name.format pattern so it can infer the format from the
extension. Only json and xml are supported. Fixtures are saved with
–indent==2 for easy perusal.