Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
How to customize the admin actions in list pages of Django admin?
Django by default provides automatic admin interface, that reads metadata from your models to provide a beautiful model interface where trusted users can manage content on your site. The admin is enabled in the default project template used by startproject so we don't need to worry of the settings. By default the model won't get displayed in the admin panel, to make the models of our application visible in the admin panel we have to regsiter the models in admin.py with admin. In models.py STATUS_CHOICES = ( ('d', 'Draft'), ('p', 'Published'), ('r', 'Review'), ('t', 'Trash'), ) class BlogPost(models.Model): title = models.CharField(max_length=100) content = models.TextField() status = models.CharField(max_length=1, choices=STATUS_CHOICES) created_date = models.DateTimeField(auto_now_add=True) def __str__(self): return self.title In admin.py admin.site.register(BlogPost) Customizing the admin actions: When we register our app with the admin we’ll see the table in the admin panel. By default it will come with ‘delete selected’ action in the list page. Now we want to add some actions like Publish the selected posts or Draft the selected posts. then we would be override the ModelAdmin and write our … -
django-html-validator now supports Django 2.x
django-html-validator is a Django project that can validate your generated HTML. It does so by sending the HTML to https://html5.validator.nu/ or you can start your own Java server locally with vnu.jar from here. The output is that you can have validation errors printed to stdout or you can have them put as .txt files in a temporary directory. You can also include it in your test suite and make it so that tests fail if invalid HTML is generated during rendering in Django unit tests. The project seems to have become a lot more popular than I thought it would. It started as a one-evening-hack and because there was interest I wrapped it up in a proper project with "docs" and set up CI for future contributions. I kinda of forgot the project since almost all my current projects generate JSON on the server and generates the DOM on-the-fly with client-side JavaScript but apparently a lot of issues and PRs were filed related to making it work in Django 2.x. So I took the time last night to tidy up the tox.ini etc. and the necessary compatibility fixes to make it work with but Django 1.8 up to Django 2.1. … -
How to Use Bootstrap 4 Forms With Django
This is a quick tutorial to get you start with django-crispy-forms and never look back. Crispy-forms is a great application that gives you control over how you render Django forms, without breaking the default behavior. This tutorial is going to be tailored towards Bootstrap 4, but it can also be used with older Bootstrap versions as well as with the Foundation framework. The main reason why I like to use it on my projects is because you can simply render a Django form using `` and it will be nicely rendered with Bootstrap 4, with very minimal setup. It’s a really life saver. Installation Install it using pip: pip install django-crispy-forms Add it to your INSTALLED_APPS and select which styles to use: settings.py INSTALLED_APPS = [ ... 'crispy_forms', ] CRISPY_TEMPLATE_PACK = 'bootstrap4' Setup Bootstrap You can either download the latest Bootstrap 4 version at getbootstrap.com. In that case, go to download page and get the Compiled CSS and JS version. Or you can use the hosted Bootstrap CDN: <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script> For simplicity, I will be using the CDN version. Here is my base.html template that will be referenced in the following examples: <!doctype … -
How to Build a Unique Technology for Your Fintech Product with Python
Fintech is a maze. It’s a thrilling and extremely complex industry for software development. There are state level regulations, integrations with different services and institutions, bank API connections, etc. to deal with. Another challenge is the high level of trust from the end users required to run finance, mortgages, investments and such. These, in turn, require the highest level of security, functionality, and correspondence with requirements. What I’m trying to say is that the more unique the software is, the higher it’s valued. Without a properly working and trustworthy software, any financial venture will die down and lose worth. People need financial technology that will last, and I’m going to tell you how we achieved this with Python/Django technological stack while developing fintech products. It’s especially pleasant to say after Python has become the world’s most popular coding language. Fintech: The Importance of Being Unique In the world of finance, there are two streams that still coexist. On one hand, there are the millennials who stride gloriously into the future while mastering contactless payments, using on-line banking and all kinds of digital financing services. In an effort to avoid old school bureaucracy, they build their lives in a way that … -
4 Strategies for Integrating Voice Technology into Your Business
In the world of business, voice technology holds astonishing potential. It can transform how your people work, or how your customers interact with your business or buy your products. Smart businesses are starting to think about how they can use voice to improve their operations or their customer experience. The post 4 Strategies for Integrating Voice Technology into Your Business appeared first on Distillery. -
4 Strategies for Integrating Voice Technology into Your Business
In the world of business, voice technology holds astonishing potential. It can transform how your people work, or how your customers interact with your business or buy your products. Smart businesses are starting to think about how they can use voice to improve their operations or their customer experience. The post 4 Strategies for Integrating Voice Technology into Your Business appeared first on Distillery. -
Individual member of the Django Software Foundation
Last Saturday, somewhen late at night when we came back home from our trip to the city, I received an unexpected mail. I was nominated, seconded and approved to be an Individual Member of the Django Software Foundation. This came completely unexpected and honestly caught me a bit off guard. I let it sink in a bit and accepted the invitation on Sunday, with a nice glass of scotch next to me. I have been using Django since 0.96-svn or so and I have been using it to ship production software for a decade. (Yes, I was actually crazy enough to bet on a pre 1.0 release framework instead of TurboGears which was a bit more established, had a nicer ORM and some really nice JavaScript integration.) During all those years I experienced a warm, welcoming and inclusive community that is also able to talk tech. This is a very nice combination. I have seen communities which are also welcoming and inclusive but lacked the technical capabilities to drive a project forward. And I have seen technical capable communities I would not want to spent five minutes with in a room full of liquor. Django was and still is the … -
Individual member of the Django Software Foundation
Individual member of the Django Software Foundation Last Saturday, somewhen late at night when we came back home from our trip to the city, I received an unexpected mail. I was nominated, seconded and approved to be an Individual Member of the Django Software Foundation. This came completely unexpected and honestly caught me a bit off guard. I let it sink in a bit and accepted the invitation on Sunday, with a nice glass of scotch next to me. I have been using Django since 0.96-svn or so and I have been using it to ship production software for a decade. (Yes, I was actually crazy enough to bet on a pre 1.0 release framework instead of TurboGears which was a bit more established, had a nicer ORM and some really nice JavaScript integration.) During all those years I experienced a warm, welcoming and inclusive community that is also able to talk tech. This is a very nice combination. I have seen communities which are also welcoming and inclusive but lacked the technical capabilities to drive a project forward. And I have seen technical capable communities I would not want to spent five minutes with in a room full of … -
Hackathon 2018: Kegerator 2—Revenge of the Flowmeter
Hackathon 2018: Kegerator 2—Revenge of the Flowmeter Morgan Senkal Wed, 08/01/2018 - 21:25 Read more about Hackathon 2018: Kegerator 2—Revenge of the FlowmeterAdd new comment If you’re going to spend two long days frying a Raspberry Pi and fiddling with (very) finicky electronics, is there any better way to do it than surrounded by beer? -
Congratulations to NetCloak on Joining the Techstars LA Class of 2018!
Congratulations to NetCloak on their acceptance into the Techstars LA startup accelerator program! In this week’s announcement, the tech incubator lauded the incredible breadth and depth of talent in the local startup ecosystem. Having had the chance to work with NetCloak’s impressive leadership team and staff first-hand, we agree that the forward-looking enterprise cybersecurity startup is a fantastic addition to Techstars LA’s Class of 2018. The post Congratulations to NetCloak on Joining the Techstars LA Class of 2018! appeared first on Distillery. -
Congratulations to NetCloak on Joining the Techstars LA Class of 2018!
Congratulations to NetCloak on their acceptance into the Techstars LA startup accelerator program! In this week’s announcement, the tech incubator lauded the incredible breadth and depth of talent in the local startup ecosystem. Having had the chance to work with NetCloak’s impressive leadership team and staff first-hand, we agree that the forward-looking enterprise cybersecurity startup is a fantastic addition to Techstars LA’s Class of 2018. The post Congratulations to NetCloak on Joining the Techstars LA Class of 2018! appeared first on Distillery. -
Configurer les représentations textuelles qui seront utilisées dans les ChoiceField des forms Django.
Longtemps que je n’avais pas posté de billets dans cette partie du blog. (Vous allez me dire longtemps que je n’ai pas posté de billet tout court, et vous auriez raison, mais ma bonne résolution de fin de vacances d’été est de changer cela). Mais donc, pour reprendre doucement dans la partie technique, je vais commencer par partager un truc que tout le monde connaît sûrement déjà. Sauf que perso, j’oublie à chaque fois que cette fonctionnalité de django existe et donc je galère pour la retrouver. Du coup je me dis qu’en l’écrivant je finirais par la mémoriser (et donc en fait j’écris plus pour moi qu’autre chose, je suis un vilain !:) ). Donc imaginons que vous avez un modèle. Truc assez classique. Ce modèle vous lui avez défini une représentation textuelle de base avec str . Sauf que vous avez plusieurs forms, donc certains ont des ChoiceFields utilisant ce modèle (Exemple un modèle User et vous avez un modèle Post où vous devez choisir le rédacteur du billet). Et manque de chance, vous avez besoin d’une représentation textuelle différentes de celle de base pour un de vos forms. Où même pire, vous avez besoin de plusieurs représentations … -
Understanding the User Experience: Why It’s Time to Get Comfortable with Talking About Emotions
When we discuss the “user experience,” or UX, as it is commonly known, words such as prototype, pain points, A/B testing, information architecture, wireframes, and site map get thrown around. However, it’s likely that neither you nor your users are familiar with these terms and concepts. The post Understanding the User Experience: Why It’s Time to Get Comfortable with Talking About Emotions appeared first on Distillery. -
Understanding the User Experience: Why It’s Time to Get Comfortable with Talking About Emotions
When we discuss the “user experience,” or UX, as it is commonly known, words such as prototype, pain points, A/B testing, information architecture, wireframes, and site map get thrown around. However, it’s likely that neither you nor your users are familiar with these terms and concepts. The post Understanding the User Experience: Why It’s Time to Get Comfortable with Talking About Emotions appeared first on Distillery. -
My Todoist Setup
What is this?Like a lot of others my first experience with todo managers was actually Wunderlist. At the time I was a college student and it was great for helping keep track of projects and other assignments. I never really dove to deep into GTD or any real kind of process then. It was just a bunch of tasks messily thrown in one project with dates attached. As college went on and I started freelancing I quickly realized I needed more help. That's when I started working on this system.Why Todoist?Eventually Microsoft bought Wunderlist. A truly sad day for Wunderlist fans, as Microsoft has a slight history of destroying things they buy. This gave me a good reason to find a new todo manager though. I looked at everything available (and still spend to much time looking at new ones now!), but finally settled on Todoist Premium.I love Todoist minimal interface, managers like Any.do and Asana just had to much clutter. Todoist also offers a really brilliant input interface as well. When adding tasks to Todoist you can add information (Projects, tags, due date, priority, etc) about the task just by typing, no need for clicking or special key bindings! … -
Leaving Webfaction
When I was young Five years ago (2013), when I made my first steps on Web Development, building localhost (dummy) projects I never thought of deployment or security issues. That's the beauty of working locally. You think, write it down, convert it to code, run it and done. Job's done. But, I wanted to make my work available to the public. What's the point of building a house, decorate it, paint it but with no guests at all? The point is to share. To evolve. I was building (still do) Django-based websites and when the time had come to upload it somewhere I did a research. Few players on the board for Python applications. My best bet back then (with no knowledge about web servers, security, redirects, static files handling etc) was to rely on a shared hosting service. I had rejected virtual private services (VPS) since I had absolutely no idea about how to setup a server with a Django application. Remember, it was 5 years ago, Django was at 1.6 release (if I recall correctly), I was just learning HTML, CSS, JS, Git etc and I had my app ready to deploy. I wrote down on a paper … -
Web Development Tutorial: PHP vs. Python & Django
In this tutorial, we'll compare PHP and Python (Django) for web development then we'll see how to create simple demo apps with PHP and Python (using Django one of the most popular frameworks for Python). PHP is a programming languages which has a sole purpose to create back-end web applications while Python is a general purpose programming language that can be used for web development and other fields such as data science and scientific calculations so our comparison will be between PHP and Python equipped with a web framework. The most popular web frameworks for Python are Django and Flask with Django being more popular than Flask. In order to compare PHP with Django we need to consider many factors such as: Are your a beginner or experienced developer? Are looking for quick insertion in the job market? etc. More experienced developers have more potential to quickly learn a new programming language than beginners Both PHP and Python are popular languages. They are both extremely popular among web developers and power most of the websites on the web today. Let's take a look at these three factors: Popularity of PHP and Python with Django for web development The learning curve … -
Changing Default Python 3 in Terminal for Mac OS
Sometimes Python gets upgraded... -
Pipenv Virtual Environments for Python
`Pipenv` is an **amazing** rep... -
Equivalents in Python and JavaScript. Part 4
In the last three parts of the series of articles about analogies in Python and JavaScript, we explored lots of interesting concepts like serializing to JSON, error handling, using regular expressions, string interpolation, generators, lambdas, and many more. This time we will delve into function arguments, creating classes, using class inheritance, and defining getters and setters of class properties. Function arguments Python is very flexible with argument handling for functions: you can set default values there, allow a flexible amount of positional or keyword arguments (*args and **kwargs). When you pass values to a function, you can define by name to which argument that value should be assigned. All that in a way is now possible in JavaScript too. Default values for function arguments in Python can be defined like this: from pprint import pprintdef report(post_id, reason='not-relevant'): pprint({'post_id': post_id, 'reason': reason}) report(42)report(post_id=24, reason='spam') In JavaScript that can be achieved similarly: function report(post_id, reason='not-relevant') { console.log({post_id: post_id, reason: reason});}report(42);report(post_id=24, reason='spam'); Positional arguments in Python can be accepted using the * operator like this: from pprint import pprintdef add_tags(post_id, *tags): pprint({'post_id': post_id, 'tags': tags}) add_tags(42, 'python', 'javascript', 'django') In JavaScript positional arguments can be accepted using the ... operator: function add_tags(post_id, ...tags) … -
Pipenv Tutorial for Django Developers
Pipenv is the new officially recommended packaging tool for Python which is similar to modern package managers like NPM (Node.js) or Composer (PHP). Pipenv solves common problems, most Python developers, encounter in the typical workflow using pip and virtualenv or venv. This tutorial will teach you to use Pipenv for managing Python dependencies and how to use the traditional existing tools, such as Pip and virtualenv, with Pipenv. Pipenv Tutorial for Django Developers: Pipenv vs. Pip vs. virtualenv vs. venv Pipenv vs. Pip vs. Virtualenv vs. Venv Multiple Project with Different Versions of Dependencies Pipenv vs Pip Dependency Resolver Getting Started with Pipenv with Django Example Create a Django Project Using Pipenv with Existing Projects Conclusion Pipenv vs. Pip vs. Virtualenv vs. Venv When working with Python projects you usually use a requirements.txt and Pip to install the packages automatically (pip install -r requirements.txt) on your development machine or later on your production machine. An example requirements.txt looks like: Django distribute dj-database-url psycopg2 wsgiref Each line contains a dependency that Pip will install, either globally or in a virtual environment if it's activated. We didn't specify the required versions which will install the latest versions of the wanted packages. Now, … -
Equivalents in Python and JavaScript. Part 3
This is the 3rd part of 4-article series about analogies in Python and JavaScript. In the previous parts we covered a large part of the traditional Python 2.7 and JavaScript based on the ECMAScript 5 standard. This time we will start looking into Python 3.6 and JavaScript based on the ECMAScript 6 standard. ECMAScript 6 standard is pretty new and supported only the newest versions of browsers. For older browsers you will need Babel to compile your next-generation JavaScript code to the cross-browser-compatible equivalents. It opens the door to so many interesting things to explore. We will start from string interpolation, unpacking lists, lambda functions, iterations without indexes, generators, and sets! Variables in strings The old and inefficient way to build strings with values from variables is this concatenation: name = 'World'value = 'Hello, ' + name + '!\nWelcome!' This can get very sparse and difficult to read. Also it is very easy to miss whitespaces in the sentence around variables. Since Python version 3.6 and JavaScript based on the ECMAScript 6 standard, you can use so called string interpolation. These are string templates which are filled in with values from variables. In Python they are also called f-string, because … -
Plain text pypi description formatting: possible cause
Sometimes projects have a plaintext description on pypi.org. You see the restructuredtext formatting, but it isn't applied. See my own z3c.dependencychecker 2.4.2 for example. I use an editor with restructuredtext syntax highlighting. I double-checked everything. I used docutils. I used pypi's own readme_renderer to check it. Not a single error. But still, after some tries, the formatting was still off. Then a fellow contributor adjusted one of the setup() keywords in our setup.py: something might have to be a string (as in another package, with a perfectly-rendering description) instead of a list (as we had). Sadly, no luck. But it made me investigate the other keyword arguments. I noticed, next to long_description, the description. This is normally a one-line description. In our case, it was a multi-line string: long_description = u'\n\n'.join([ ... some files .... ]) description = """ Checks which imports are done and compares them to what's in setup.py and warns when discovering missing or unneeded dependencies. """ setup( name='z3c.dependencychecker', version=version, description=description, long_description=long_description, I changed it to a single line and yes, the next release worked fine on pypi! (Note that I also toyed a bit with encodings in that pull request, but I don't think that had … -
Equivalents in Python and JavaScript. Part 2
Last time we started a new series of articles about analogies in Python and JavaScript. We had a look at lists, arrays, dictionaries, objects, and strings, conditional assignments, and parsing integers. This time we will go through more interesting and more complex things like serializing dictionaries and lists to JSON, operations with regular expressions, as well as raising and catching errors. JSON When working with APIs it is very usual to serialize objects to JSON format and be able to parse JSON strings. In Python it is done with the json module like this: import jsonjson_data = json.dumps(dictionary, indent=4)dictionary = json.loads(json_data) Here we'll indent the nested elements in the JSON string by 4 spaces. In JavaScript there is a JSON object that has methods to create and parse JSON strings: json_data = JSON.stringify(dictionary, null, 4);dictionary = JSON.parse(json_data); Splitting strings by regular expressions Regular expressions are multi-tool that once you master, you can accomplish lots of things. In the last article, we saw how one can join lists of strings into a single string. But how can you split a long string into lists of strings? What if the delimiter can be not a single character as the comma, but a … -
A few JavaScript Functions for Images and Files
> This post will be updated as...