Skip to content

Instantly share code, notes, and snippets.

@wolever
wolever / reverseadmin.py
Last active June 21, 2023 06:48 — forked from mzbyszewska/reverseadmin.py
Forked from https://gist.github.com/mzbyszewska/8b6afc312b024832aa85 , updated to work with Django 1.8
'''
adminreverse from here http://djangosnippets.org/snippets/2032/
changed for working with ForeignKeys
'''
'''
reverseadmin
============
Module that makes django admin handle OneToOneFields in a better way.
A common use case for one-to-one relationships is to "embed" a model
inside another one. For example, a Person may have multiple foreign
@niyazpk
niyazpk / pQuery.js
Created October 25, 2014 14:03
Add or update query string parameter
// Add / Update a key-value pair in the URL query parameters
function updateUrlParameter(uri, key, value) {
// remove the hash part before operating on the uri
var i = uri.indexOf('#');
var hash = i === -1 ? '' : uri.substr(i);
uri = i === -1 ? uri : uri.substr(0, i);
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
if (uri.match(re)) {
@mzbyszewska
mzbyszewska / reverseadmin.py
Last active June 21, 2018 16:32 — forked from ramusus/gist:4343464
Forked from ramusus: https://gist.github.com/ramusus/4343464 and changed to work in Django 1.6, changes tested for OneToOne relation only (original version for Django 1.1 at https://djangosnippets.org/snippets/2032/.)
'''
adminreverse from here http://djangosnippets.org/snippets/2032/
changed for working with ForeignKeys
'''
'''
reverseadmin
============
Module that makes django admin handle OneToOneFields in a better way.
A common use case for one-to-one relationships is to "embed" a model
@blackfalcon
blackfalcon / git-feature-workflow.md
Last active April 13, 2024 07:33
Git basics - a general workflow

Git-workflow vs feature branching

When working with Git, there are two prevailing workflows are Git workflow and feature branches. IMHO, being more of a subscriber to continuous integration, I feel that the feature branch workflow is better suited, and the focus of this article.

If you are new to Git and Git-workflows, I suggest reading the atlassian.com Git Workflow article in addition to this as there is more detail there than presented here.

I admit, using Bash in the command line with the standard configuration leaves a bit to be desired when it comes to awareness of state. A tool that I suggest using follows these instructions on setting up GIT Bash autocompletion. This tool will assist you to better visualize the state of a branc

@pylemon
pylemon / using_request_post_or_none.py
Created April 7, 2012 16:34
django: using(request.POST or None) hack in views | advanced forms usage
# simple form usage in view
def my_view(request, template_name='home.html'):
# sticks in a POST or renders an empty form
form = MyForm(request.POST or None)
if form.is_valid():
do_something()
return redirect('/')
return render_to_response(template_name, {'form':form})
# form with files
@marijn
marijn / README.markdown
Last active October 1, 2023 13:42
List of countries in YAML, CSV and TXT format