django

Creating views in django (string indentation problems)

I am new to both Python (and django) - but not to programming. I am having no end of problems with identation in my view. I am trying to generate my html dynamically, so that means a lot of string manipulation. Obviously - I cant have my entire HTML page in one line - so what is required in order to be able to dynamically build an html ...

Query all rows and return most recent of each duplicate

Hey guys, I've got a model that has an id that isn't unique. Each model also has a date. I would like to return all results but only the most recent of each row that shares ids. The model looks something like this: class MyModel(models.Model): my_id = models.PositiveIntegerField() date = models.DateTimeField() title = model...

How to switch L10N in django

LANGUAGE_CODE = 'ru-RU' USE_I18N = True # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale USE_L10N = False {{ post.date_added|date:"b" }} gives "окт" in templates. If I set USE_I18N = False then it gives oct as it should be. Is this a bug ? How can I solve this problem ?...

How to print Django's runserver output to a file?

hi, when i develop my django app locally, i use python manage.py runserver and all errors messages (like Error 500 ...) are printed in the terminal. It is useful because it enables to put some printin the code and check the values of some variables. But when the app is executed via fastgci on a remote server i can't see those messages....

How can I disabled debug navigation in django-cms?

I always see "selected (Level:" or "Sibling" next to each menu element. What I should do to disable this information from my website. ...

Responding to httpRequest after using threading.Timer to delay response

Hey everyone, I'm trying to patch a testing framework built in python for javascript called mootools-test-runner (i'm a front end developer by day, so my python skills are pretty weak... really weak.) The use case is we want to be able to make a json request to the server and have it delay x amount of time before it returns -- original...

Django queryset custom manager - refresh caching

Hi all, In my userprofile model, I have a method (turned into a property) that returns a queryset based on another model's custom manager. Concretely, a user can sell non-perishable and perishable items, and on the Item model level, several custom managers live that contain the logic (and return the querysets) for determining whether a...

Django development version vs stable release

I am about to start ramping up on Django and develop a web app that I want to deploy on Google App Engine. I learn that Google has Django 0.96 already installed on the APP engine, but the latest "official" version of Django I see is at 1.2.3 and its a bit of an effort to install it there. I am curious which version of Django is most wid...

How do I forcefully clean a field and redisplay it in Django?

How can I clean the data in a form and have the cleaned data redisplayed instead of the submitted data? There are several fields in my form, and every time the user submits it, it should be redisplayed with the values the user entered. However, some of the fields I would like to clean and update for the user. More specifically, I have ...

Dynamically choose which base template to extend in django

I have content that is going to be the exact same between the mobile and web site. The only thing i want to change is the base template. One base template for the mobile HTML, and one for the website HTML. One solution is to wrap the render_to_response and determine which HTML to render, but I'd still have two files. Is there a way I c...

django ModelMultipleChoiceField (default values)

I`ve been searching and trying to get this to work for the past few hours and I cant ... I have a list of skills that I take from the database forms.ModelMultipleChoiceField( skills.objects.all(), required=True, widget=forms.CheckboxSelectMulti...

Django: Generating a queryset from a GET request

I have a Django form setup using GET method. Each value corresponds to attributes of a Django model. What would be the most elegant way to generate the query? Currently this is what I do in the view: def search_items(request): if 'search_name' in request.GET: query_attributes = {} query_attributes['color'] = request...

Move a python / django object from a parent model to a child (subclass)

I am subclassing an existing model. I want many of the members of the parent class to now, instead, be members of the child class. For example, I have a model Swallow. Now, I am making EuropeanSwallow(Swallow) and AfricanSwallow(Swallow). I want to take some but not all Swallow objects make them either EuropeanSwallow or AfricanSwall...

django: extend flatpages for a specific application

I have a portfolio application that lists projects and their detail pages. Every project generally has the same information (gallery, about etc. ), but sometimes the user might want to add extra information for a particularly large project, maybe an extra page about the funding of that page for example. Would it be possible to create a...

Installing MySQLdb on Snow Leopard

Hello, I followed this tutorial to install Django with MySQL on my Snow Lepard : http://programmingzen.com/2007/12/22/how-to-install-django-with-mysql-on-mac-os-x/ When I run this command : python setup.py build I get a lot of errors, the last one is : error: command 'gcc-4.0' failed with exit status 1 These are the first lines t...

Multiple Items in django-paypal

I am using dcramer's version of django-paypal(but i think it shouldnt matter whether it is dcramer or johnboxall's). 1) How can i specify multiple items in my paypal_dict(to be used in PayPalPaymentsForm)? 2) Also, i need to suitably specify the shipping cost and the individual quantities in the Summary that appears in the Paypal screen...

my Django development (needs advice)

I am writing a website using Django. I need to push the web site out as soon as possible. I don't need a lot of amazing things right now. I am concern about the future development. If I enable registration, which means I allow more contents to be writable. If I don't, then only the admins can publish the content. The website isn't exac...

how to customize sorting order in django ForeignKey field

Hello. I have this code: class Article(models.Model): # usefull staff category = models.ForeignKey("Category") class Category(models.Model): parent = models.ForegnKey('self') I want to display categories selector as a <select> field with sorted category tree in it. It should look like top level category1 lower level...

Django - Replicating the admin list_display

What's the easiest method to get list_display functionality in my main website (outside of the admin pages). I have a group of elements I'd like to select and perform an action. Any ideas? ...

Python md5 password value

I have this change password request form.In which the user enter their oldpasswords. this oldpassword is the md5 format. How to compare the md5 value from db to the oldpassword entered by user import md5 oldpasswd_byuser=str("tom") oldpasswd_db="sha1$c60da$1835a9c3ccb1cc436ccaa577679b5d0321234c6f" opw= md5.new(oldpasswd_byuse...