The easiest way to expose the user list to use the django-rest-framework, using the recipe detailed in django-rest-frameworks , all Django user objects are pulled by default at once and stored in Redis for quick access.

One important change from the guide is to configure your serializer like this, the 'id' field is crucial for the integration.

class UserSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = User
        fields = ('url', 'id', 'username', 'email', 'groups', 'first_name', 'last_name', 'last_login', 'date_joined')

Testing

I would recommend using a third party tool like Postman to test the API to minimize the possibility of a client bug causing an issue. Django will certainly have a few issues. Be sure to enable digest authentication and you must authenticate as a superuser to pull all the users.

Integration

From the picoevent control console, open the Django Integration accordion tab. Enter the API address, you tested before with the same username and password, press the button Test. When the test is complete, press the Connect button to integrate the API.

While picoevent is connected, every time there is a cache miss, all the users will be retrieved from the Django database and stored in Redis.

This may not be efficient for sites with huge user bases, but again that's what's great about open source software, you can easily, build on this to make a complex solution particular to your application.

Security: The security your Django superuser credentials relies on the Flask SECRET_KEY being stored securely (not in version control).

Posting events tied to Django users

Certainly the easiest way would be to copy the standalone PicoEventRestClient.py Python 3 module and call it directly it has been extensively tested and requires no dependencies for Python 3.6

Initialize PicoEventRestClient with the endpoint of your picoevent rest blueprint. If you just run locally it will be http://localhost/api by default as well as an API key which you may create from the picoevent web control panel.

client = PicoEventRestClient(ENDPOINT, API_KEY)
event_data = {"view": import inspect;inspect.stack()[0][3], #  Not sure if this is a good general purpose solution
                "ip_address": request.META["REMOTE_ADDR"],
                "referrer": request.META["HTTP_REFERER"],
                "user_agent": request.META["HTTP_USER_AGENT"]}
client.post(event_type_id,event_data,request.user.id)
# IMPORTANT: the user_id is optional and the call will succeed without it, perhaps confusing you to why the integration is not working

The call is synchronous but usually lighting fast as the recommend configuration is to use the nginx instance running django to forward the call to the picoevent backend. (To comply with the same origin policy for the upcoming JavaScript client)

If you are unsure of the event_type_id (they might have changed for whatever reason), you can use the list_event_id method. This is not recommended for every request, it would be better to setup some sort of cached solution.

In the near future, a JavaScript rest client will be available which should give you more flexibility.

Viewing events

Open the picoevent web control panel, in another browser you should see the events coming up live with only a slight sdelay.

Forums
Technical Support