django

Django with fastcgi and threads

I have a Django app, which spawns a thread to communicate with another server, using Pyro. Unfortunately, it seems like under fastcgi, multiple versions of this thread are fired off, and a dictionary that should be globally constant within my program, isn't. (Sometimes it has the values I expect, sometimes not) What's the best way to e...

Most optimal way to programmatically check if site is running locally or on a server with Django?

Currently I have this in my settings.py file: DEBUG = True LOCAL = True TEMPLATE_DEBUG = DEBUG SITE_TITLE = 'Stack Overflow Question' REMOTE_SITE_URL = "http://************:8080" LOCAL_SITE_URL = "http://************:8000" ADMINS = ( # ('Your Name', '[email protected]'), ) MANAGERS = ADMINS if LOCAL: SITE_URL = LOCAL...

Django: Two way one-to-one relationship. Chick or egg?

What is the appropriate way to create an instance of the following two models class Administrator(models.Model): user = models.OneToOneField(User, primary_key=True) account = models.ForeignKey(Account) class Account(models.Model): owner = models.OneToOneField(Administrator) Both require each other. An account cannot exist...

Creating custom Exceptions that Django reacts to

For my site I created an abstract Model which implements model-level read permissions. That part of the system is completed and works correctly. One of the methods the permissioned model exposes is is_safe(user) which can manually test if a user is allowed to view that model or not. What I would like to do is add a method to the effec...

Django, delete all cookie

Hello, I want to delete all cookies for the user under my domain name. I know logout() method removes the session,but it seems like some of my apps are generating afew more cookies that needs to be cleansed. How can I achieve this? ![alt text][1] ...

Positional Rankings and Dealing with Ties in Python

(I apologize that previous versions of this question displayed the wrong function that I need to fix, this has been remedied and I hope the question makes a little more sense now.) I have a list of objects with scores, and I'm attempting to assign rank to them based on those scores. Below is basically how I output my data. sorted_score...

Building a wiki application?

Hi folks, I'm building this app in Python with Django. I would like to give parts of the site wiki like functionality, but I don't know how to go on about reliability and security. Make sure that good content is not ruined Check for quality Prevent spam from invading the site The items requiring wiki like functionality are just a f...

importerror: No module named django

I installed python 2.6 alongside my mac's 2.5.2 version. As soon as I did, python2.6 manage.py runserver failed because it couldn't find django.core.management. From a shell, import django returns importerror: No module named django. Why? ...

Django: When using register.inclusion_tag() where/what order is the template searched for?

When using the register.inclusion_tag() shortcut on a Custom Template Tag, assuming you define the template as 'some_fragment.html', in what directories/order does Django try to find that template? Assume as many 'defaults' as is reasonable. The Custom Template Tag portion of the documentation doesn't list anything specific, except t...

Django FormSets as Fields of another Form

I have a Django model that looks like this: DEFAULT_PROFILE_INFO = [ {"name":"About Me", "body":"Super programmer", "public":True}, {"name":"Research", "body":"Various topics", "public":False} ] class Profile(models.Model): user = models.OneToOneField(User, unique=True) info = JSONField(blank=True, default=DEFAULT_PROFI...

Basic Django - Custom Managers

I'm going through the Django book and I'm currently on chapter 10. I'm having a problem understanding the third line in this fragment of code: class DahlBookManager(models.Manager): def get_query_set(self): return super(DahlBookManager, self).get_query_set().filter(author='Roald Dahl') I understand that this custom manager...

RSS feed stats in Django?

I have a Django site segmented into different city and neighborhood sub-sections. I want to serve an RSS feed for each. Easy. Problem is I wanted to use Feedburner for stats, monetization etc but each feed would need to be split out manually into its own feedburner URL. There are hundreds of cities and neighborhoods. I have to roll my ow...

Listing installed python site-packages ?

from distutils.sysconfig import get_python_lib; print get_python_lib() Returns: /usr/lib/python2.6/site-packages import sys; print sys.path Returns: ['', '/usr/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg', '/usr/lib/python2.6/site-packages/pip-0.6.3-py2.6.egg', '/usr/lib/python2.6/site-packages/TRML2PDF-1.0-py2.6.egg', '/usr/...

how do i set my 'Connect URL'and 'Canvas Callback URL' in facebook.

...

Building Solr indexes through Haystack throws unknown field error

I'm trying to integrate Haystack with Solr. When I try to build the index, I get an error "Unknown field django_id" from SOLR. What's causing this to happen? ...

cannot import name formats

what does it mean? i ve googled but found nothing =/ ImportError at /admin/ cannot import name formats Request Method: GET Request URL: http://127.0.0.1:8000/admin/ Exception Type: ImportError Exception Value: cannot import name formats Exception Location: /usr/lib/python2.6/site-packages/django/contrib/admin/util.py in <modul...

why my facebook content can't come back. i used pyfacebook.

i follow this article step by step http://wiki.developers.facebook.com/index.php/User:PyFacebook_Tutorial#Add_the_middleware 1。 2。 3。 i want to return my site, but it login facebook,how to return to my site ?? 4。 this is my settings in facebook. 5. i set this: Canvas Callback URL http://zjm1126qqcom.gicp.net:8000/ C...

modeling extra table information with django's contenttypes

I've just started using Django's contenttypes framework (and it's pretty awesome). I have an Area object that has many specialised Block objects - I've modeled it as below. class Area(models.Model): ... class SomeBlock(models.Model): ... class AreaBlock(models.Model): area = models.ForeignKey(Area) content_type = model...

Editing the raw HTML inside a TinyMCE control

I have a Django website in which I use django-tinymce to edit HTML fields with a TinyMCE control. TinyMCE practically gives me a WYSIWYG way to edit HTML. My question is, can I get access to edit the underlying HTML directly? I was thinking, maybe there's some button I can enbale which will toggle between "WYSIWYG mode" and "raw html mo...

Adding arbitrary extensions to URLs generated by Django

Django has excellent URLConf and URL reverse mapping/matching. I'm looking for a tip/trick to add arbitrary extensions to URLs generated by Django. Sometimes it's nice to see extensions that suggest your brand. ...