Saravanan666/pypi-org huggingface dataset:
Package: django-ws
django-wsHelpers for using WebSockets in DjangoInstallationpip install django-wsSetupasgi.pyRemove line:from django.core.asgi import get_asgi_applicationRemove line:application = get_asgi_application()Add to the end:fromdjango_wsimportget_websocket_applicationapplication=get_websocket_application()ws_urls.pyNext to your rooturls.pycreate aws_urls.pylike the example below that uses your websocket.fromdjango.urlsimportpathimportmyapp.wsurlpatterns=[path('ws',myapp.ws.MySocket),]Write a WebSocketfromdjango_wsimportWebSocketHandlerclassMySocket(WebSocketHandler):asyncdefon_open(self):do_something_on_open()asyncdefon_message(self,data):do_something_on_msg()# send json dataself.send({"reply":"sending data back"})asyncdefon_close(self):do_something_on_close()More Featuresstart_ping methodUsage:self.start_ping()Sends a ping{'ping': timezone.now().isoformat()}every 59 seconds to keep the websocket alive. Sometimes this is needed with certain deployment environments.start_task methodUsage:self.start_task(<task_id>, <coroutine>)Example:self.start_task('send_weather', self.send_weather)Creates anasyncio background task.django-wshandles tracking duplicate tasks by ID and cancelling tasks during interruptions such as disconnects. Note: you still need to be careful about long running processing. Even if youawaita long running function, it will block the socket from closing. So do things in small chunks that can be interrupted.sleep_loop methodUsage:await self.sleep_loop(<coroutine>, <seconds:int>)Example:await self.sleep_loop(self._send_weather, 60 * 3)Does an infinite loop and sleeps for the given seconds after each sleep. Uses an async sleep so that it does not block other tasks.MiddlewareWebsockets in general follow a different lifecycle then HTTP requests.This means websockets in Django do not have a pre-established middleware mechanism. However, middleware is still helpful with websockets.Websocket MiddlewareThe websocket middleware functions much like the standard Django request/response middleware; however, since websockets open a long lived connection and messages are received and sent asynchronously it works slightly different.This middleware is good for authenticating the initial websocket connections, and performing setup and tear down.Websocket middleware setup insettings.py:WS_MIDDLEWARE=['myproject.middleware.AuthAsyncMiddleware',]Example middleware:fromimportlibimportimport_modulefromasgiref.syncimportsync_to_asyncfromdjango.contribimportauthfromdjango.confimportsettingsclassAuthAsyncMiddleware:def__init__(self,func):self.func=funcasyncdef__call__(self,ws):print('Pre Run Loop')ifnothasattr(ws.request,'user'):engine=import_module(settings.SESSION_ENGINE)SessionStore=engine.SessionStoresession_key=ws.request.COOKIES.get(settings.SESSION_COOKIE_NAME)ws.request.session=SessionStore(session_key)ws.request.user=awaitsync_to_async(auth.get_user)(ws.request)print('USER:',ws.request.user)ret=awaitself.func(ws)print('POST Run Loop')returnret
Package: django-ws4ever
==============django-ws4ever==============提供基于gevent的websocket的handlerQuick start-----------1. Install::pip install django_ws4ever2. Add "ws4ever" to your INSTALLED_APPS setting like this::INSTALLED_APPS = [...'ws4ever',]3. complete your own websocket handler class::from ws4ever.views import BaseWebSocketApplicationclass WebSocketClientApplication(BaseWebSocketApplication):def __init__(self, ws):passdef handle_message(self, kind, payload=None):pass4. set the websocket config path::# ws4ever confWS4EVER = {'ROUTES': { #websocket path and handler class"/ws": "django_ws4ever.views.WebSocketClientApplication"},'MAX_IDLE': 30,  # seconds, interval to check zombie websocket connections'NOTIFY_BACKEND': 'redis://:password@redis-host:redis_port/db_id' # or 'memory'}5. patch gevent in manage.py::#prepend these code before any python code, possibly in line 2from gevent import monkey;monkey.patch_all(thread=False)6. runserverpython manage.py runserver7. test websocket in js::var ws = new WebSocket("ws://localhost:8000/ws");ws.onopen = function(){console.log("on open");ws.send(JSON.stringify({kind:'kind', payload:'payload'}));};ws.onmessage = function (evt){var received_msg = evt.data;console.log("receive message", received_msg);};ws.onclose = function(){console.log("Connection is closed...");};8. [Optional] if you want to use wsgi to run websocket(ig.use gunicorn), config wsgi like that8.1 config project wsgi.py::#append to tail, must after  os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xx.settings")# gunicorn 用的 websocket wsgifrom geventwebsocket import Resourcefrom ws4ever.helpers import get_websocket_sourcesws_application = Resource(get_websocket_sources())8.2 run gunicorn like::#replace wsgi path to your own, replace your port`gunicorn -k "geventwebsocket.gunicorn.workers.GeventWebSocketWorker"   django_ws4ever.wsgi:ws_application --bind 127.0.0.1:8001`9. [Optional/Advanced] broadcast and receive message9.1 config broadcast backend::you can send notify via redis or memory.Via redis, you can send notification to multi processes; via memory, you can only send notification in current process.You are supposed to use memory in development and redis in production environment.in settings.py::WS4EVER = {...'NOTIFY_BACKEND': 'redis://:password@redis-host:redis_port/db_id' # or 'memory'}9.2 can send broadcast by::from ws4ever.redis import notify_clientsnotify_clients('kind', 'payload', extra_field='extra_value', extra_field2='extra_value2')9.3 then can handle the messages in WebSocketClientApplication you created in step 3 above::class WebSocketClientApplication(BaseWebSocketApplication):...@classmethoddef on_notify(cls, kind, payload, **extra):#add your handle code here
Package: django-ws-analytics
django-ws-analyticsoffers a novel approach to user tracking within Django applications, circumventing the need for cookies by leveraging request metadata. This package computes a unique hash value for each user, derived from their IP, device type, browser, and system specifications, enabling seamless user identification and analytics.Key FeaturesCookie-less Tracking: Utilize request metadata for user identification, offering privacy-compliant tracking.Customizable Tracking: Adjust tracking parameters and configurations to match specific analytics needs.GeoIP Integration: Leverage MaxMind’s GeoIP databases for enriched location data and insights.Extensible Example: A fully functional Django example project to demonstrate setup and usage.Getting StartedPrerequisitesA MaxMind account for GeoIP databases.Sign up here.InstallationInstalldjango-ws-analyticsusing pip:pipinstalldjango-ws-analyticspythonmanage.pymigrateDjango Project ConfigurationTo fully integratedjango-ws-analyticsinto your Django project, make the following adjustments in yoursettings.py:Database Engine: It’s crucial to use PostGIS as your database engine for the analytics to function correctly:DATABASES={'default':{'ENGINE':'django.contrib.gis.db.backends.postgis','NAME':os.environ.get('POSTGRES_DB','ws_analytics'),'USER':os.environ.get('POSTGRES_USER','ws_analytics'),'PASSWORD':os.environ.get('POSTGRES_PASSWORD','ws_analytics'),'HOST':os.environ.get('POSTGRES_HOST','localhost'),'PORT':os.environ.get('POSTGRES_PORT','5432'),}}Middleware, Installed Apps, and Analytics Configuration: Ensure the required middleware and apps are included, and configure the analytics behavior:MIDDLEWARE=[...'django.contrib.sessions.middleware.SessionMiddleware','ws_analytics.middleware.AnalyticsMiddleware',...]INSTALLED_APPS=[...'django.contrib.sessions','django.contrib.gis','django_user_agents','ws_analytics',...]WS_ANALYTICS_CONFIG={'SESSION_COOKIE_AGE':30*60,# Session ID expiration (default: 30 minutes)'SESSION_COOKIE_NAME':'_sid','DEVICE_COOKIE_AGE':60*60*24*365,# Device ID expiration (default: 1 year)'DEVICE_COOKIE_NAME':'_did','LOGGABLE_VIEW_NAMES':['home'],# Specify view names for tracking'SESSION_SAVE_EVERY_REQUEST':False,'GEOIP_PATH':os.environ.get('GEOIP_PATH','GeoIP2-City.mmdb'),}GeoIP Library Paths: Specify the paths for GDAL and GEOS libraries if they’re not automatically detected:GDAL_LIBRARY_PATH=os.environ.get('GDAL_LIBRARY_PATH')GEOS_LIBRARY_PATH=os.environ.get('GEOS_LIBRARY_PATH')
Package: django-wsgi
django-wsgi unlocks Django applications so developers can take advantage of the
wealth of existing WSGI software, as the other popular Python frameworks do. It
won’t break you existing Django applications because it’s 100% compatible with
Django and you can start using the functionality offered by this library
progressively. It should be really easy to get started, particularly for
developers who are familiar with frameworks like Pylons or TurboGears.
Package: django-wsgi2
# django-wsgi2django-wsgi2is a fork ofdjango-wsgithat:
1. Is compatible with Django 3.0.
2. Integrates easier (especially in production).## InstallationThis package can be installed from pip3:` pip3 installdjango-wsgi2`## ConfigurationIn the original [django-wsgi documentation](https://pythonhosted.org/django-wsgi/“django-wsgi documentation”) the configuration is based on modifying theWSGI_APPLICATIONsetting value in settings.py. This is enough for development purposes but does not work in a production environment. In a production environment, it is not clear the location of the WSGI application that the HTTP server has to target requests to. The documentation was vague about this point, so this package provides an alternative:This is how django-wsgi2 is configured both for testing and production:In your Django project wsgi.py file (project_root/project_name/wsgi.py), replace this line:`python from django.core.wsgi import get_wsgi_application `for this:`pyton from django_wsgi.handler import get_wsgi_application `That is all you need to do.## DocumentationAdditionanl documentation for django-wsgi2 can be found in the original django-wsgi package [documentation](https://pythonhosted.org/django-wsgi/).
Package: django-wsgi3
# django-wsgi2django-wsgi3is a fork ofdjango-wsgi2that has been modified to be compatible with Django 4.2.## InstallationThis package can be installed from pip3:` pip3 installdjango-wsgi2`## ConfigurationIn the original [django-wsgi documentation](https://pythonhosted.org/django-wsgi/“django-wsgi documentation”) the configuration is based on modifying theWSGI_APPLICATIONsetting value in settings.py. This is enough for development purposes but does not work in a production environment. In a production environment, it is not clear the location of the WSGI application that the HTTP server has to target requests to. The documentation was vague about this point, so this package provides an alternative:This is how django-wsgi2 is configured both for testing and production:In your Django project wsgi.py file (project_root/project_name/wsgi.py), replace this line:`python from django.core.wsgi import get_wsgi_application `for this:`pyton from django_wsgi.handler import get_wsgi_application `That is all you need to do.## DocumentationAdditionanl documentation for django-wsgi2 can be found in the original django-wsgi package [documentation](https://pythonhosted.org/django-wsgi/).
Package: django-wsgi-view
django-wsgi-view================.. image:: https://img.shields.io/pypi/v/django-wsgi-view.svg:target: https://pypi.python.org/pypi/django-wsgi-view:alt: Latest PyPI version:crossorigin: anonymousEmbed WSGI application as Django view.Requirements------------- Python >= 3.6- Django >= 1.10Installation------------You can install ``django-wsgi-view`` via `pip`_ from `PyPI`_::$ pip install django-wsgi-view.. _`pip`: https://pypi.python.org/pypi/pip/.. _`PyPI`: https://pypi.python.org/pypiUsage-----``urls.py`` module in your project:.. code:: pythonfrom django.conf.urls import urlfrom wsgi_view import WsgiViewurlpatterns = [url(r'^sub-app(/.*)', WsgiView.as_view(application='wsgi.app')),]
Package: django-ws-scoring
OverviewTheManipulateQuerySetclass, part of thedjango-ws-scoringpackage, enhances Django querysets by applying custom relevancy scores. It analyzes user history, such as search terms and locations, to dynamically adjust the relevance of queryset items. This functionality is designed to improve user experience in data-driven Django applications by providing personalized content ranking and search result customization.FeaturesPreprocess User History: Assigns relevancy weights to user history data based on the recency and frequency of search terms and locations.Calculate Relevancy: Dynamically adjusts the relevancy of queryset items based on calculated scores and defined field weights.Customizable Field Weights: Allows setting flexible weights for different model fields to fine-tune the relevancy scoring mechanism.DependenciesDjangoPandasNumpydjango-pandasTo install these dependencies, run:pipinstalldjangopandasnumpydjango-pandasUsageTo utilize theManipulateQuerySetclass within your Django project, follow this example where user history data influences the ranking of job listings.Defining User History ModelAssumingUserHistoryis a model that captures user interactions:fromdjango.dbimportmodelsimportuuidclassUserHistory(models.Model):keyword_search=models.TextField(null=True,blank=True)location_search=models.CharField(max_length=255,null=True,blank=True)created_at=models.DateTimeField(auto_now_add=True)session_id=models.UUIDField(default=uuid.uuid4,editable=False)ApplyingManipulateQuerySetIn your view or queryset logic:importws_scoring.module_ws_scoringaswsfrommyapp.modelsimportUserHistoryimportuuiddefget_annotated_queryset(request):user_history=UserHistory.objects.filter(session_id=uuid.UUID('12345678-1234-5678-1234-567812345678'))field_weight_dict={'title':10,'location':7,}manipulator=ws.ManipulateQuerySet(queryset=JobListing.objects.prefetch_related('location'),user_history=user_history,field_weight_dict=field_weight_dict,)annotated_qs=manipulator.calculate_relevancy()returnannotated_qsThis script retrievesUserHistoryrecords for a specifiedsession_id, defines weights for thetitleandlocationfields of theJobListingmodel, and appliesManipulateQuerySetto calculate and adjust relevancy scores, producing an annotated queryset.CustomizationAdjust thefield_weight_dictto include any relevant fields for your application, modifying the weights to reflect their significance in relevancy scoring.For comprehensive documentation on Django’s model queries and queryset manipulation, refer to theDjango documentation.
Package: django_wtfd
wtfd(write the f*ing docs) is a Django library that forces developers to write docstrings.Developed on Django 1.5.8Installationpip install django_wtfdAdd django_wtfd to your project’s INSTALLED_APPS.SettingsWTFD_APPSList of project’s apps to include in docstrings check. If its not set all the .py files in project will be checked.WTFD_STRICTIf set to True, checks will raise an exception in case some method/function/class is missing docstrings. Defaults to False.UsageTo perform docstrings check, run: ./manage.py wtfdNotesDocstrings check skips magic methods, migrations, Meta class and modules that have ‘test’ in their name.
Package: django-wunderground
django-wunderground=================NOTE: This project, forked from MegaMark16, was made more generic,as it includes a template tag that can look up weather by ZIP code.An extension for Django CMS that pulls current weather informationbased on the website visitor's IP address and displays it on thescreen.  You will need a www.wunderground.com API key to use this.Dependancies============- django (tested with 1.4)- django-cms (tested with 2.3.5)- django-classy-tags (tested with 0.4)Getting Started=============To get started simply install using ``pip``:::pip install django-wungergroundAdd ``wunderground`` to your installed apps.Add WUNDERGROUND_KEY to your settings file.::WUNDERGROUND_KEY = 'abcdefgh12345678'Usage=============Simply drop a Current Local Weather plugin on a page.  You will probablywant to override the ``wunderground/local_weather.html``or ``wunderground/local_weather_tag.html``templates.  Any of the fields from the wunderground.com "conditions" apicall should be available in the template under the context variable``weather_info``.Template tag-------------This library provides a simple template tag:::{% current_weather %}When provided with a variable, it attempts to look it up using WUnderground'sgeocode API, which usually expects a ZIP/Postal code:::{% current_weather '04421' %}Will display the weather in Castine, Maine.
Package: django-wx
=====django-wx=====django-wx is a simple Django app to conduct Web-based wechat. For eachquestion, visitors can choose between a fixed number of answers.Detailed documentation is in the "docs" directory.Quick start-----------1. Add "wechat" to your INSTALLED_APPS setting like this::INSTALLED_APPS = [...'wechat',]2. Include the wechat URLconf in your project urls.py like this::path('wx/', include('wechat.urls')),3. Run `python manage.py migrate` to create the wechat models.4. Start the development server and visit http://127.0.0.1:8000/admin/to create a poll (you'll need the Admin app enabled).5. Visit http://127.0.0.1:8000/wx/ to participate in the django-wx.
Package: django-wxmgmt
=====wxmgmt=====简单的Django应用，配置管理微信公众号，包括用户的管理、消息模板的管理，自定义菜单的管理tenant：公众号信息，account：关注用户的信息Quick start-----------1. Add "wxmgmt" to your INSTALLED_APPS setting like this::INSTALLED_APPS = [...'wxmgmt',]2. Include the polls URLconf in your project urls.py like this::path('wxmgmt/', include('wxmgmt.urls')),3. Run `python manage.py migrate` to create the wxmgmt models.4. Start the development server and visit http://127.0.0.1:8000/admin/to create a tenant (you'll need the Admin app enabled).5. Visit http://127.0.0.1:8000/wxmgmt/ to participate in the poll.
Package: django-wxpolls
Polls is a simple Django app to conduct Web-based polls. For each
question, visitors can choose between a fixed number of answers.Detailed documentation is in the “docs” directory.Quick startAdd “polls” to your INSTALLED_APPS setting like this:INSTALLED_APPS = [
    ...
    'polls',
]Include the polls URLconf in your project urls.py like this:path('polls/', include('polls.urls')),Runpython manage.py migrateto create the polls models.Start the development server and visithttp://127.0.0.1:8000/admin/to create a poll (you’ll need the Admin app enabled).Visithttp://127.0.0.1:8000/polls/to participate in the poll.
Package: django-wymeditor
A Django application that contains a widget to render a form field with aWYMEditorinterface.RequirementsCurrently integration with django-filebrowser or django-bfm is hard-coded in.
This will be fixed in a future version. For now, make sure you have django-
filebrowser installed and included in yourINSTALLED_APPS, and that one of
the following is in your URLconf:# For django-filebrowser

urlpatterns += patterns('',
    (r'^admin/filebrowser/', include('filebrowser.urls'))
)


# For django-bfm

# Hack for WYMEditor hardcoded link URL... :-(
from django.views.generic import RedirectView
urlpatterns += patterns('',
    url(r'^admin/filebrowser/browse/', RedirectView.as_view(url="/admin/files/")),
    url(r'^admin/files/', include('django_bfm.urls'))
)With that, you should have full filebrowser integration w/ WYMEditor.
Package: django-wysiwyg-image
django-wysiwyg-imageAn easy way to paste images to wysiwyg editors in Django admin interface. All it needs from you is to upload an image through standard Django interface, and you will get a URL to provide to your wysiwyg editor.Requirements:Application was tested with Python 3.6 and Django 2.2, 3.2Installation:Install usingpip...pip install django-wysiwyg-imageAdd'wysiwyg_img'to yourINSTALLED_APPSsetting.INSTALLED_APPS = [
    ...
    'wysiwyg_img',
]Usage:Important! This tutorial does not cover basic Django configurations, installations of third party apps like django-tinymce, Pillow etc.Let's imagine we have apostsapp in Django project withPostmodel in which we want to paste images by wysiwyg editor in admin interface(in our case django-tinymce editor). First up we're going to importBaseImageModelfromwysiwyg_img.modelsand inherite from it ourPostImagemodel. Then we have to tiePostImagemodel toPostmodel byForeignKey. Now ourmodels.pyfile should look like this:from django.db import models

from tinymce import models as tinymce_models

from wysiwyg_img.models import BaseImageModel


class Post(models.Model):
    title = models.CharField(max_length=100)
    tiny_mce = tinymce_models.HTMLField()


class PostImage(BaseImageModel):
    post = models.ForeignKey(Post, on_delete=models.CASCADE)Run./manage.py makemigrationsand./manage.py migrate.Do not forget to install django-tinymce and Pillow before running migrations.We also need to do some configurations inadmin.pyfile of current application:from django.contrib import admin

from wysiwyg_img.admin import ImageInline

from posts.models import Post, PostImage


class PostImageInline(ImageInline):
    model = PostImage

class PostAdmin(admin.ModelAdmin):
    inlines = [
        PostImageInline,
    ]

admin.site.register(Post, PostAdmin)The last step is to create a superuser to access the admin interface. That's all! Now in admin interface we have fields to download unlimited images associated withPostmodel. Each field hasLINK TO PASTEvalue to provide to your WYSIWYG editor. Just copy it and paste to the editor window. Pay attention! Editors may not include image plugins by default. Fields also have thumbnails and delete checkboxes for convenient way of managing images.Settings:There are two possible configurations available throughdjango.conf.settingsmodule.WYSISWYG_IMG_UPLOAD_TODefault: ''String represents path to downloaded images under yourMEDIA_ROOT. It works exactly asFileField.upload_to.Important! Every time you change this setting, you must runmakemigrationsandmigratecommand to create and apply migrations.WYSISWYG_IMG_IMAGE_WIDTHDefault: 150Integer represents thumbnail width in Django admin interface.NoteNeitherdjango-wysiwyg-imageapp nor Django itself removes images from your file system automatically when you hit the delete button. So you'll have to implement the removal of images yourself. Or you can use a brilliant app for that purpose:django-cleanup.
Package: django-xadmin
Drop-in replacement of Django admin comes with lots of goodies, fully extensible with plugin support, pretty UI based on Twitter Bootstrap.Live Demohttp://demo.xadmin.ioUser: adminPassword: adminFeaturesDrop-in replacement of Django adminTwitter Bootstrap based UI with theme supportExtensible with plugin supportBetter filter, date range, number range, etc.Built-in data export with xls, csv, xml and json formatDashboard page with widget supportIn-site bookmarkingFull CRUD methodsScreenshotsGet StartedInstallXadmin is best installed via PyPI. To install the latest version, run:pipinstalldjango-xadminor Install from github source:pipinstallgit+git://github.com/sshwsfc/django-xadmin.gitInstall Requiresdjango>=1.4django-crispy-forms>=1.2.3 (For xadmin crispy forms)django-reversion([OPTION] For object history and reversion feature, please select right version by your django, seechangelog)xlwt([OPTION] For export xls files)xlsxwriter([OPTION] For export xlsx files)DocumentationEnglish (coming soon)ChineseChangelogs0.5.0Update fontawesome to 4.0.3Update javascript files to compact fa icons new versionUpdate tests for the new instance method of the AdminSite classAdded demo graphsAdded quickfilter plugin.Adding apps_icons with same logic of apps_label_title.Add xlsxwriter for big data export.Upgrade reversion models admin list page.Fixed reverse many 2 many lookup giving FieldDoesNotExist error.Fixed user permission check in inline model.DetailOnline GroupQQ群 : 282936295Run Demo Locallycddemo_app./manage.pyrunserverOpenhttp://127.0.0.1:8000in your browser, the admin user password isadminHelpHelp Translate :http://trans.xadmin.io