django

using properties in Django Admin

I have a model with field defined as p = models.DecimalField(max_digits=12, decimal_places=6) But the decimal_places=6 is only for internal accuracy. I only want 2 decimal_places to show up in the admin fields. So I thought perhaps I could do something with properties. But properties don't show up as fields in the Admin interface. E.g...

Looking for a resource which provides django templates

Hello all, I'm pretty handy with django and python but I'm terrible at the "visual" aspect of the web-design. Even after quite a bit of google-ing I haven't been able to find any sort of resource that has download-able templates complete with css, images, etc. that could be used to set up a basic website easily. I'm looking for example...

Custom django form fields

I am trying to get if required "*" within lable tag. Somewhat close to this <label for="id_name"><strong>Name</strong> <em>*</em></label> With label_tag {{ field.label_tag }} it generates as <label for="id_city">City</label> this begins and closes label tag, how to insert "*" before closing this hack seems to work, <label fo...

django filter older than day(s)?

The day is number user will input to get the result that older than (days from user input) for example if user 32 days will get the results that oder than 30days. A quick try-out: class Entry(models.Model): entered = models.DateTimeField() >>> from datetime import datetime >>> Entry(entered = datetime.now()).save() >>> Entry.objec...

Django: Running site on many languages

Hi, I want to run an article site on several languages, I already translated translation strings, so my templates are ready. I only have a questions how to store articles in many languages? Should I create a database for each translation or it works in different way? If I have for example this basic model: class Article(models.Model):...

Filter older than ...day In django?

def get_filter_result(self, customer_type='',last_contact_filled='', tag_selected='', city_selected=''): qdict = {} if customer_type != '': qdict['type__name'] = customer_type qdict['active']=True #MY PROBLEM IS HERE get result that older than last_contact_filled day(s) if last_cont...

Filter with field has relationship in Django?

I have these models in Django: class Customer(models.Model): def __unicode__(self): return self.name name = models.CharField(max_length=200) class Sale(models.Model): def __unicode__(self): return "Sale %s (%i)" % (self.type, self.id) customer = models.ForeignKey(Customer) total = models.DecimalField...

update django database to reflect changes in existing models

I've already defined a model and created its associated database via manager.py syncdb. Now that I've added some fields to the model, I tried syncdb again, but no output appears. Upon trying to access these new fields from my templates, I get a "No Such Column" exception, leading me to believe that syncdb didn't actually update the datab...

Django - leaving messages to (offline) users using the new messages framework

So message_set is deprecated in favor of the new messages framework. The good old message_set allowed me to leave messages to offline users (for example, when I do some stuff in a cron job I may want to notify some user about that). Now take a glance at the new framework and it seems that a message can only be added to the request object...

django inline editing - inline form only required if at least one field is filled out

Hi, I created a view which returns a form including a contact form and two phone_number forms, following this example: multiple forms The phone number forms should only be validated if the user inserts at least a value for one field in a phone number form. For example: a phone number has a type and a number. If the user is selecting ...

Where should I place the one-time operation operation in the Django framework?

I want to perform some one-time operations such as to start a background thread and populate a cache every 30 minutes as initialize action when the Django server is started, so it will not block user from visiting the website. Where should I place all this code in Django? Put them into the setting.py file does not work. It seems it wil...

Finding all classes that derive from a given base class in python

I'm looking for a way to get a list of all classes that derive from a particular base class in Python. More specifically I am using Django and I have a abstract base Model and then several Models that derive from that base class... class Asset(models.Model): name = models.CharField(max_length=500) last_update = models.DateTime...

django delete problem - deleting more than one object with a OneToOneField relationship - got MultipleObjectsReturned error

I have a problem with deleting my objects. I wrote a delete method which get a list of IDs of objects to be deleted. This works fine for objects and for objects with foreign keys, but it fails if i have a OneToOneField relationship to the object which i want to delete. This is my delete method: @login_required def delete_objects(reques...

HTML Form Building / Django request.POST help

I'm not sure if I'm just form building impaired or not thinking about this the right way. I'm attempting to build a form similar to Gmail's 'compose' form that has an AJAX image uploader. I have a portion of code that uploads the image and returns an image ID working fine. Once I receive the image ID back I've tried appending it to my...

How to get Permissions to inherit from User's Groups?

I'm trying to figure out Django Groups and the documentation is pretty bare on the site. For example, you can use the decorator permission_required() to check the permissions, however, this only checks if you have assigned permissions directly. I have assigned Users to Groups which have Permissions setup. When using Django's permissio...

django change label in a included .html form template - e.g. from "Add" to "Save"

I have written a form template to be used in different templates with the include tag. {% include "crm/contact_form.html" %} This form includes a submit button. Now I want to change the label of the button according to the circumstances the form is used. For example if the form is included in a add template the label should be "Add...

Safely rendering user provided django templates

So as per a previous question of mine I've decided to start a website which allows django designers to upload templates and css files. I'll provide a well defined set of context inputs and objects and then render the templates that the users provided. This will hopefully give newbies a large set of examples to work from and designers a...

satchmo can't handle 500 error

If the quantity of the product is a Unicode character, I get UnicodeEncodeError at /add/. When I set DEBUG = False, the satchmo can't handle 500 error,it can't return an HttpResponse object, but the handler404 is ok. I find the following in the apache error log. [Thu Dec 31 23:05:31 2009] [error] [client 192.168.123.124] mod_wsgi (pid=1...

Django Nested Relations

I'm not sure if I just can't concentrate or what, but I feel like this should be easy to do. I have 2 models, one that references the other as a simple foreign key relation (one-to-many) now in the template I want to display this relation as a nested unordered lists. ...

Why do many django contain a '__init__.py'

Many directories in a django project contain a __init__.py and I think it will be used as initialization for something. Where is this __init__.py used? ...