django

Django: Admin, adding some new filters to a multiple choise field

Hi! I am building an article site using django. I've added many to many relation between my articles this way: class Article (models.Model): # Tiny url url = models.CharField(max_length = 30, unique=True) is_published = models.BooleanField() author = models.CharField(max_length = 150) title = models.CharField(max_le...

Storing wiki revisions on Google App Engine/Django - Modifying This Existing Code

In the past, I created a Django wiki, and it was fairly straightforward to make a Page table for the current wiki entries, and then to store old revisions into a Revision table. More recently, I decided to set up a website on Google App Engine, and I used some wiki code that another programmer wrote. Because he created his Page model in...

problem with filtering in a referenceproperty dropdown - Django

I have the following problem. I have a contact class that different users can tag with their own topics: class Contact(db.Model): contact_date = db.DateProperty(auto_now_add=True) remarks = db.TextProperty() topic = db.ReferenceProperty(Topic) class Topic(db.Model): topic = db.StringProperty(required=True) des...

django Unicode GET Parameter Values

I'm trying to get a GET parameter value that looks like this: http://someurl/handler.json?&q=%E1%F8%E0%F1%F8%E9 The q parameter in this case is Hebrew. I'm trying to read the value using the following code: request.GET.get("q", None) I'm getting gybrish instead of the correct text. Any idea what's wrong here? Am I missing some ...

django and executing a separate .py to manipute a database

Hello, I want to execute a random .py file, say foo.py on the myproject/myapp folder by using crobjob by some periods I have this basic model in my model.py for the app: class Mymodel(models.Model): content = models.TextField() Say I have this in my foo.py, I want to check if there is any Mymodel object that has a content field a...

'TemplateDoesNotExist' error with creating Sitemap for Django app

I followed the sitemap activation steps on the django site but i keep getting a 'TemplateDoesNotExist' error. Maybe i am misunderstanding, but isn't genericview supposed to generate the page? ########### url.py #############################3 ......... from django.contrib.sitemaps import FlatPageSitemap, GenericSitemap ........ ...........

Custom Django-admin command issue

Hello, trying to understand how custom admin commands work, I have my project named "mailing" and app inside named "msystem", I have written this retrieve.py to the mailing/msystem/management/commands/ folder and I have pasted an empty init.py both to the management and cpmmands folders. from django.core.management.base import BaseComma...

Django database scalability

Hi ALL: We have a new django powered project which have a potential heavy-traffic characteristic(means a heavy db interaction). So we need to consider the database scalability in advance. With some researches, the following questions are still not clear to us: coarse-grained: how to specify one db table(a django model) to a specific d...

Django: How to model a MySQL VARBINARY HEX Field? (solved)

I am trying to model a VARBINARY MySQL field in Django v1.1.1. The binary field stores a hexadecimal representation of data (i.e. one would use INSERT INTO test(bin_val) VALUES X'4D7953514C') Reading the Django documentation[1] I came up with this sollution: class MyTest(models.Model): bin_val = BinValField() class BinValField(mod...

Django Object Filter (last 1000)

How would one go about retrieving the last 1,000 values from a database via a Objects.filter? The one I am currently doing is bringing me the first 1,000 values to be entered into the database (i.e. 10,000 rows and it's bringing me the 1-1000, instead of 9000-1,000). Current Code: limit = 1000 Shop.objects.filter(ID = someArray[ID])[:l...

How to prepare a django project for future changes

As I work on my first django powered site, I am constantly learning new things and making all sorts of changes and additions to my apps as I go. I try to follow DRY and pythonic principles and be smart in my coding but eventually I will have to take the site live and am certain that not long after I do, something new and exiting will co...

Complex query in Django

Maybe a simple question, but i've just started to work with Django after a few years of php experience :-) Problem: we have a pair of models - "Categories" and "Post". "Categories" is nested sets tree of post categories, "Post" is plain list of blog posts with ForeignKey field, linked to Categories model. Here is an example: class Cate...

django - simplelazyobject breaks template filter

Here's a template filter that has been working without problems till recently, before I updated Django source: from pm_core.models import PMUser @register.filter def can_manage_market(user, market): if not isinstance(user, PMUser): return False return user.can_manage_market(market) The filter has begun to return false al...

Cache a django view that has URL parameters.

I have recently implemented Django's excellent cache framework. However from what I understand Django will not cache a view that is passed parameters in a get request. I have an Ajax view that is passed get parameters that I would like to cache for X seconds, what would be an easy way to do this? In psuedo code I currently have a URL: ...

How do I use inline formsets to link two or more forms?

Hi, I have the following models and I'd like to use them to generate a contact form...now I know I'm suppossed to use inline formsets, but I've never been able to make heads or tails of how to make this work...I want to have the first name, last name, email, phone number, best time to contact, and the message in my view. class BestTi...

How to use twistedweb with django on windows.

I'm looking for a super easy way to deploy django application on windows. Basically my plan is to set up any python web server with my app on it and the boundle everything together using py2exe into a single executable. I've tried using cherrypy however the newest (3.1.2) server doesn't work with Windows XP with Nod32 antivirus install...

Currently using Django "Evolution", is "South" better and worth switching?

I'm currently using Django evolutions to manage my product's database evolutions. It's not perfect but I've learned to live with its flaws. For instance, I always have to copy my production database to test before moving out a new schema because the "evolve" command cannot always evolve a database that was changed in several small migr...

How do I DRY up common text in a Django template?

I have some static text that needs to show up at 2 locations within a template. For example: <div> {% if something %} This is a static text {% else %} Something else happened {% endif %} </div> ... more html <span> {% if something %} This is a static text {% else %} Something else happend {% endif %} </span> I can ...

How to use nested template tags with arguments?

I would like to learn how I can use nested template tags where the child template tag takes an argument like below: {% parent_tag {% child_tag arguments %} rest_of_parent_arguments %} In the above line, I would like to use the return value of child tag as an argument to the parent tag. ...

Rendering different part of templates according to the request values in Django

In my view to render my template I receive different parameters through my request. According to these parameters I need to render different "part" in my templates. For example let say that if I receive in my request to_render = ["table", "bar_chart"] I want to render a partial template for table and an other for bar_chart to_rende...