To match only the homepage in an .htaccess rule, match %{REQUEST_URI} to ^/$
The following will rewrite to a new page only for the homepage.
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^$ v2/pages/home/index.php
Yuji's Increasingly Infrequent Ramblings
To match only the homepage in an .htaccess rule, match %{REQUEST_URI} to ^/$
The following will rewrite to a new page only for the homepage.
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^$ v2/pages/home/index.php
I was using a 4 year old installation of nginx (0.7) – apt-get update, apt-get install nginx claimed I had the latest version…
Turns out this error means the return directive isn’t supported in the `return 301 foo.com` format until a later nginx.
Install the latest nginx by following the docs at http://wiki.nginx.org/Install
sudo -s nginx=stable # use nginx=development for latest development version add-apt-repository ppa:nginx/$nginx apt-get update apt-get install nginx
I was having an odd issue where {% url ‘custom_admin:foo_bar_changelist’ %} would work from one admin but not another location. I put it on Stack Overflow… got an answer that one can manually construct the adminsite include via include(adminsite.get_urls(), ‘app_name’, ‘namespace’).
Got an error suddenly starting in the past 2 days (2013) that my API connection failed due to “SSL Required”.
{"errors":"SSL required"}
This exact error means you need to use HTTPS in your api requests.
Broke at a critical time for us.
Wow, I had to dig into the source of DataTables 1.9.3 to figure out why a regular expression with no “smart filter” was failing.
Turns out each column is returning massively padded data due to the HTML blocks containing spaces.
Trim it to match regexps that rely on position like ^$ (blank) or .+ (1+). Those extra leading/trailing whitespace chars are the problem.
Go to the DataTables source… look at this function and trim whitespace from sData:
Note that there may be an API for overriding internal functions… but I can’t be bothered to look right now. This has been a long debug.
*/
function _fnFilterColumn ( oSettings, sInput, iColumn, bRegex, bSmart, bCaseInsensitive )
{
if ( sInput === "" )
{
return;
}
var iIndexCorrector = 0;
var rpSearch = _fnFilterCreateSearch( sInput, bRegex, bSmart, bCaseInsensitive );
for ( var i=oSettings.aiDisplay.length-1 ; i>=0 ; i-- )
{
var sData = _fnDataToSearch( _fnGetCellData( oSettings, oSettings.aiDisplay[i], iColumn, 'filter' ),
oSettings.aoColumns[iColumn].sType );
if ( ! rpSearch.test( sData.trim() ) ) ////////// add .trim() here
I have a model that is being shared across many different forms. An ugly side effect of this was that if I ever forgot to ensure that the HTML rendered contained *exactly* the fields defined in the form, django would overwrite the values.
Here’s a mixin that you can add to any ModelForm which will only update values.
Note that this still allows users to update a model field explicitly with a blank.
from django.forms.models import model_to_dict
from django import forms
class OverwriteOnlyModelFormMixin(object):
'''
Delete POST keys that were not actually found in the POST dict
to prevent accidental overwriting of fields due to missing POST data.
'''
def clean(self):
cleaned_data = super(OverwriteOnlyModelFormMixin, self).clean()
for field in cleaned_data.keys():
if self.prefix is not None:
post_key = '-'.join((self.prefix, field))
else:
post_key = field
if post_key not in self.data:
# value was not posted, thus it should not overwrite any data.
del cleaned_data[field]
# only overwrite keys that were actually submitted via POST.
model_data = model_to_dict(self.instance)
model_data.update(cleaned_data)
return model_data
When there is no obvious reason why this error suddenly appears on a working datatables instance…
Make sure your
cdvirtualenv
This is stupid.
All htaccess, php.ini, define_ methods failed.
This is what works:
Download this
http://sxi.sabrextreme.com/phpini
Put it on your server.
Go to it with your browser.
Click install.
Navigate to the mywordpress.com/cgi-bin folder and edit php.ini
Find max_upload_size and modify to whatever you want.
find max_post_size and modify to whatever you want.
This is stupid.
I just followed the source back from django’s ClearableFileInput all the way to django’s model field magic… all the way to a little thing called FieldFile.
FieldFile can be faked with these minimum attributes:
from django.core.files.storage import default_storage
class FakeField(object):
storage = default_storage
fieldfile = FieldFile(None, FakeField, file_path)
form = SomeForm(initial={'filefield': fieldfile })
WHEW!