Find a link that contains a specific word using BeautifulSoup

You can do it with a simple “contains” CSS selector: soup.select(“a[href*=location]”) Or, if only one link needs to be matched, use select_one(): soup.select_one(“a[href*=location]”) And, of course, there are many other ways – for instance, you can use find_all() providing the href argument which can have a regular expression value or a function: import re soup.find_all(“a”, … Read more

Changing column width in react-table

In react-table v7 you need to use a layout hook (useBlockLayout, useAbsoluteLayout or useFlexLayout) so the specified width is applied. Important: all those hooks set a default column width to 150px. You can see an example in Full Width Resizable Table. In react-table v8 you can use the attributes size, minSize and maxSize on the … Read more

Centering grid items in an auto-fill container

Flexbox The most efficient solution to your problem is probably flexbox, as flex items are not confined to individual tracks (columns/rows) like grid items. .grid { display: flex; flex-wrap: wrap; margin-bottom: 1em; } .item { flex: 1 0 100px; background: #eee; text-align: center; border: 1px dashed gray; box-sizing: border-box; } <div class=”grid”> <div class=”item”>Item 1</div> … Read more

Include CSS and Javascript in my django template [duplicate]

First, create staticfiles folder. Inside that folder create css, js, and img folder. settings.py import os PROJECT_DIR = os.path.dirname(__file__) DATABASES = { ‘default’: { ‘ENGINE’: ‘django.db.backends.sqlite3’, ‘NAME’: os.path.join(PROJECT_DIR, ‘myweblabdev.sqlite’), ‘USER’: ”, ‘PASSWORD’: ”, ‘HOST’: ”, ‘PORT’: ”, } } MEDIA_ROOT = os.path.join(PROJECT_DIR, ‘media’) MEDIA_URL = ‘/media/’ STATIC_ROOT = os.path.join(PROJECT_DIR, ‘static’) STATIC_URL = ‘/static/’ STATICFILES_DIRS = … Read more

CSS for element SELECT multiple=yes

First things first, in order for a select element to not be in multi-selection mode, the multiple attribute must be entirely omitted. Even if you set multiple=”no” or multiple=”false”, the standard behavior is the same as HTML multiple or XHTML multiple=”multiple”. For more information, refer to the HTML spec. With this in mind, use the … Read more

Prevent select2 from flipping the dropdown upward

Since modifying the source code is not an option and adding a hook to the select2:open event is not very elegant, especially when you have multiple select2 instances in the same page, I have written a small extension for the Select2 plugin. My implementation is inspired by a PR from the plugin’s repository (https://github.com/select2/select2/pull/4618) that … Read more

How do I get Tailwind’s active breakpoint in JavaScript?

From the tailwind docs, you can import your config from the tailwindcss node module: import resolveConfig from ‘tailwindcss/resolveConfig’ import tailwindConfig from ‘./tailwind.config.js’ const fullConfig = resolveConfig(tailwindConfig) fullConfig.theme.width[4] // => ‘1rem’ fullConfig.theme.screens.md // => ‘768px’ fullConfig.theme.boxShadow[‘2xl’] // => ‘0 25px 50px -12px rgba(0, 0, 0, 0.25)’ As you can see above, you can get your breakpoints … Read more

Bootstrap putting checkbox in a dropdown

Here’s what we’ll build: HTML Essentially, we’ll look to combine two different sets of Bootstrap controls & styles: Dropdowns & Checkboxes. Inside of each li, we’ll use a label instead of an a element, so that we can wrap the checkbox in a label and make the entire row clickable. <ul class=”dropdown-menu checkbox-menu allow-focus”> <li … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)