django-1.2

Migrating a Google App Engine application from Django 0.96 to Django 1.2

帅比萌擦擦* 提交于 2019-12-23 15:36:28
问题 I will soon start to port my different Google App Engine applications built with the default version of Django (0.96) to Django 1.2. I generally don't use any specific Django modules apart from the i18n stuff to get the websites translated. I plan to go through the backwards-incompatible changes to Django from 0.96 to 1.0 and the different Django release notes. Those are the current release notes available between 0.96 and 1.2: 1.2 release Django 1.2.5 release notes Django 1.2.4 release notes

How to create push notifications in django?

佐手、 提交于 2019-12-21 06:28:17
问题 I'd like to implement push notifications in android ? I prefer not to use an existing plugins would someone give me an example of code on how to send a message have been struggling since a week none of my tries have been successfull This is my last try: gcm.py import requests import json def send_gcm_message(api_key, regs_id, data, collapse_key=None): """ Send a GCM message for one or more devices, using json data api_key: The API_KEY from your console (https://code.google.com/apis/console,

Django compound/nested/subforms?

扶醉桌前 提交于 2019-12-20 23:28:03
问题 I'm looking for an updated version of these Django SuperForms. Can't seem to get it to work in Django 1.2. In particular, I'd like it to work with ModelForms. My use case is almost identical to his; I have an Address model that I'd like to use as a sub-form in various places. It's a pain to try and combine everything in the view func. 回答1: I've updated superforms.py to work w/1.2, and attached it to the ticket you linked to: http://code.djangoproject.com/attachment/ticket/3706/superform.2.py

django-admin: Add extra row with totals

会有一股神秘感。 提交于 2019-12-17 23:20:21
问题 I'm using the standard django admin module to display a list of rows. One of the columns is a numerical field. I'd like to display an extra 'totals' row that has most of the columns as blank, except for the numerical column, which should be the total for all of the objects. Is there a simple way to do this within the admin module, or am I better off making a custom view for it? I'm using Django 1.2. 回答1: Yes, you can do it in many ways, but most django-ist way to do is: First override the

iphone push notifications passphrase issue (pyAPns)

假装没事ソ 提交于 2019-12-17 17:39:11
问题 I'm trying to implement push notifications for iphone based on PyAPNs When I run it on local but it blocks and prompts me to enter the passphrase manually and doesn't work until I do I don't know how to set it up so to work without prompt This is my code: from apns import APNs, Payload import optparse import os certificate_file = here(".." + app.fichier_PEM.url ) token_hex = '0c99bb3d077eeacdc04667d38dd10ca1a' pass_phrase = app.mot_de_passe apns = APNs(use_sandbox=True, cert_file= certificate

Django compound/nested/subforms?

一世执手 提交于 2019-12-03 07:07:29
I'm looking for an updated version of these Django SuperForms . Can't seem to get it to work in Django 1.2. In particular, I'd like it to work with ModelForms. My use case is almost identical to his; I have an Address model that I'd like to use as a sub-form in various places. It's a pain to try and combine everything in the view func. I've updated superforms.py to work w/1.2, and attached it to the ticket you linked to: http://code.djangoproject.com/attachment/ticket/3706/superform.2.py There's a project I'm working on that could benefit from this, so I figured I'd spend the time and help you

Django 1.2: How to connect pre_save signal to class method

旧时模样 提交于 2019-12-01 04:11:16
I am trying to define a "before_save" method in certain classes in my django 1.2 project. I'm having trouble connecting the signal to the class method in models.py. class MyClass(models.Model): .... def before_save(self, sender, instance, *args, **kwargs): self.test_field = "It worked" I've tried putting pre_save.connect(before_save, sender='self') in 'MyClass' itself, but nothing happens. I've also tried putting it at the bottom of the models.py file: pre_save.connect(MyClass.before_save, sender=MyClass) I read about connecting signals to class methods here , but can't figure out the code.

Django 1.2: How to connect pre_save signal to class method

不羁的心 提交于 2019-12-01 01:39:48
问题 I am trying to define a "before_save" method in certain classes in my django 1.2 project. I'm having trouble connecting the signal to the class method in models.py. class MyClass(models.Model): .... def before_save(self, sender, instance, *args, **kwargs): self.test_field = "It worked" I've tried putting pre_save.connect(before_save, sender='self') in 'MyClass' itself, but nothing happens. I've also tried putting it at the bottom of the models.py file: pre_save.connect(MyClass.before_save,

iphone push notifications passphrase issue (pyAPns)

不羁的心 提交于 2019-11-28 04:35:29
I'm trying to implement push notifications for iphone based on PyAPNs When I run it on local but it blocks and prompts me to enter the passphrase manually and doesn't work until I do I don't know how to set it up so to work without prompt This is my code: from apns import APNs, Payload import optparse import os certificate_file = here(".." + app.fichier_PEM.url ) token_hex = '0c99bb3d077eeacdc04667d38dd10ca1a' pass_phrase = app.mot_de_passe apns = APNs(use_sandbox=True, cert_file= certificate_file) payload = Payload(alert = message.decode('utf-8'), sound="default", badge=1) apns.gateway_server

Django Model Field Default Based Off Another Field in Same Model

你。 提交于 2019-11-26 12:24:24
问题 I have a model that I would like to contain a subjects name and their initials. (The data is somewhat anonymized and tracked by initials.) Right now, I wrote class Subject(models.Model): name = models.CharField(\"Name\", max_length=30) def subject_initials(self): return \'\'.join(map(lambda x: \'\' if len(x)==0 else x[0], self.name.split(\' \'))) # Next line is what I want to do (or something equivalent), but doesn\'t work with # NameError: name \'self\' is not defined subject_init = models