Sphene Community Tools

Community

Copyright © 2007-2018 by Herbert Poul

You are not logged in.
Login
Register

Change Language:



AddThis Social Bookmark Button

A Django site.

Powered by Sphene Community Tools

SCT Development Cheat sheet

Development / Cheatsheet

A collection of useful hints i created basically for myself so i don't have to look it up everytime in code i have previously written.

These are mostly SCT-related hints, only a few may also apply to other django projects.

1. General

1.1. Reverse lookup for a view -> URL

1.1.1. in python:

from sphene.community.sphutils import sph_reverse

sph_reverse( 'view_name', args = (), kwargs = { } )

1.1.2. in templates:

{% load sph_extras %}

{% sph_url2 view_name arg=value %}

2. Models

2.1. Absolute URLs

from sphene.community.middleware import get_current_request
from sphene.community.sphutils import sphpermalink as permalink

class MyModel(models.Model):

    def get_absolute_edit_url(self):
        return ('sphene.sphblockframework.views.edit_block_config', (), { 'groupName': self.group.name, 'bock_config_id': self.id })
get_absolute_edit_url = permalink(get_absolute_edit_url, get_current_request)

Tags:

Last Modified: 2008-04-04 07:17:52 by Herbert Poul - [ Snip Changes ] [ Wiki History ]

0 Comments

No comments yet.

Please login to create a new thread.



Powered by Sphene Community Tools