Number ONE » Django
449 FOLLOWERS
This blog is dedicated to updating about Django framework, how to interact with it, new update releases and everything you need to know about Django.
Number ONE » Django
1y ago
I am using django-bootstrap3 to show django forms with bootstrap. Most of the fields have their own bootstrap widgets except for:
WIDGETS_NO_REQUIRED = (
AdminFileWidget,
HiddenInput,
FileInput,
CheckboxInput,
CheckboxSelectMultiple
)
Unfortunately that makes the CheckboxSelectMultiple render as a single line of vertical checkboxes. Not making use of space that well. So how do we change the way it is rendered?
Since django 1.11 we can now use custom renderers simply by changing the template as opposed to overriding the render method prior to django 1.11.
So ..read more
Number ONE » Django
3y ago
I think we know the security benefits and the development benefits of using a delegated authentication protocol like OpenIDC or SAML.
However, actually doing the integration in the application can be difficult at times.
There is a lack of documentation and guidance on the best modules or packages to use for the various frameworks.
In this post I will be looking at the options available for Django when authenticating with an OpenIDC provider - Keycloak.
Using Django as an OpenIDC provider is not what I want - although it is possible with the django openidc provider package
First port of call ..read more
Number ONE » Django
3y ago
There is often a case for improving the understanding of things with visualisations.
Python provides a number of libraries to create great visualisations - however they often are focused more on a data science approach - scripts and jupyter notebooks.
What we want is the visualisations to be easily accessible through a django website, that is what I will be showing in this post with a specific focus on network diagrams.
What Visualisation Package are we using
The post Displaying a network chart diagram on a Django site appeared first on Number ONE ..read more
Number ONE » Django
3y ago
This is a weird one, an error I had never got until I used an external MySQL (Maria) DB Instance with Django.
The steps to recreate this error would be:
As an Admin try and add another user from the admin section
You will get an error like this:
OperationalError /admin/auth/user/add/
error(1305, 'SAVEPOINT s139787825936192_x1 does not exist')
In my case the system had the following attributes:
CentOS 7
python mysql connecor: mysqlclient
django 2.2.15
Server version: 5.5.30 (ProxySQL)
According to this stackoverflow post on the subject, it was to do with the MySQL-Python connector.
The an ..read more
Number ONE » Django
3y ago
I've been wanting to secure my api - so unidentified and unathorized parties cannot view, update, create or delete data.
This api is internal to the company and will only be used by other services - in other words no end users.
Hence the delegation of authorization need not happen and the services will be authneticating directly with the api.
That is why the Oauth client credentials flow is used - it is for server to server communication. (As far as I know)
There is alot of conflicting information on Oauth but in the RFC6749 on Oauth 2 Client credentials is mentioned:
1.3.4. Client Credentia ..read more
Number ONE » Django
3y ago
I have used mozilla's Django OpenID Connect client before, but this time I found something called Django-AllAuth.
Django-Allauth seems packed full of features and is well maintained. So I am going to test whether I can use it with Keycloak as the identity provider for users on django and django admin.
Initial Setup
With your activated environment and existing django project:
pip install django-allauth
Add the required settings in settings.py:
AUTHENTICATION_BACKENDS = [
...
# Needed to login by username in Django admin, regardless of `allauth`
'django.contrib.auth.backends.Model ..read more
Number ONE » Django
5y ago
Let me guess you are using django and may have just done an upgrade to django 2.2.x in order to stay up to date or for posterity on vulnerabilities.
Unfortunately CentOS only has v3.7.17 in their repos.
So you need to install v3.8.3 or the latest from source.
To do that, you can install from source (I’m not sure how to use the precompile binaries)
Download the source code from sqlite downloads
cd /opt
wget https://www.sqlite.org/2019/sqlite-autoconf-3280000.tar.gz
tar -xzf sqlite-autoconf-3280000.tar.gz
cd sqlite-autoconf-3280000
./configure
make
sudo make install
You have to log out and rel ..read more
Number ONE » Django
5y ago
Ever wanted to add the time taken for a response to your API, so the client knows how long that takes?
I first noticed this cool feature on AWX, a management platform for ansible playbooks.
There’s response headers looked like this:
So I checked out their source code and copied how they did it:
In generics.py the package extends the base DRF ApiView class and adds a bit of stuff, the important stuff for us is:
def finalize_response(self, request, response, *args, **kwargs):
...
response = super().finalize_response(request, response, *args, **kwargs)
time_started ..read more