django

Django | twilio to send SMS

I'm using twilio as for a mobile verification mechanism, I have no prior experience in using twilio but looking at the sample PHP code I used this one in my code but apparently it's giving me an 400 Bad request HTTP error. Here's the code: d = { 'TO' : '*** *** ****', 'FROM' : '415-555-1212', 'BODY' : 'Hello...

how can I implement foreign Key in Form Wizard

I have 2 models connected with foreign key but when i am Implementing form wizard from orm model it is not relating both of them with each other please provide any solution ...

{% include %} vs {% extends %} in django templates

When particularly extend template and when to use include ? Is include of any use with content like user profile section (like about me in the corner of our site) ? ...

How can I obfuscate email addresses contained in 'free input' text fields in Django

In my models I often use text fields that are intended to contain large pieces of textile-formatted input. I'd like to automatically obfuscate any email addresses that are entered into these text fields, so that when they're printed in a template they're not visible to spiders. Is there a smart way to do this? Update: Based on lazersc...

how to create default users on django init_data ?

How can I loaddata for default list of users, when I syncdb ? ...

Django: How to get current user in admin forms

In Django's ModelAdmin I need to display forms customized according to the permissions an user has. Is there a way of getting the current user object into the form class, so that i can customize the form in its __init__ method? I think saving the current request in a thread local would be a possibility but this would be my last resort th...

Best way to change Satchmo checkout page fields?

For a Satchmo project we have to change the fields a customer has to fill out during checkout. Specifically, we have to: Add a 'middle name' field Replace the bill and delivery addressee with separate first, middle and last name fields Replace the two address lines with street, number and number extension These fields are expected by...

JSON Serialization of a Django inherited model

Hello, I have the following Django models class ConfigurationItem(models.Model): path = models.CharField('Path', max_length=1024) name = models.CharField('Name', max_length=1024, blank=True) description = models.CharField('Description', max_length=1024, blank=True) active = models.BooleanField('Active', default=True) ...

why datetime.now() shows invalid result when executed inside django server ?

Case 1 >>> datetime.__file__ '/usr/lib/python2.6/lib-dynload/datetime.so' >>> print datetime.datetime.now() 2010-05-19 19:45:40.202634 Case 2 from django.db import models import datetime print datetime.__file__ print "--------------------------", datetime.datetime.now() -----------Result-------- Development server is running at ht...

Django Include Aggregate Sums of Zero

I'm working on a Django timesheet application and am having trouble figuring out how to include aggregate sums that equal zero. If I do something like: entries = TimeEntry.objects.all().values("user__username").annotate(Sum("hours")) I get all users that have time entries and their sums. [{'username': u'bob' 'hours__sum':49}, {'user...

Django admin - remove field if editing an object

I have a model which is accessible through the Django admin area, something like the following: # model class Foo(models.Model): field_a = models.CharField(max_length=100) field_b = models.CharField(max_length=100) # admin.py class FooAdmin(admin.ModelAdmin): pass Let's say that I want to show field_a and field_b if the u...

Is there a built-in login template in django

Hello All Dear Developers, Django is awesome. It has a built-in adminstration system. I have to write very less code to implemente user management module. I want to let user sign in before seeing some page. Is there any built-in template for user sign-in, so that I do not have to write my own sign in page. Best regards ...

How to properly set path to media files in Django

Hello. I've got a new project, and currently I'm trying to set it correctly. But somehow I can't make my media files work. Here's my current setting : MEDIA_ROOT = os.path.normpath( '/home/budzyk/rails/fandrive/site_media/' ) templates setting work on the other hand : TEMPLATE_DIRS = ( "/home/budzyk/rails/fandrive/templates",...

Is there an elegant way to have a list_filter for a M2M field in the Django admin?

If I have a Pizza model and a Topping model, with m2m between them, is there some quick elegant way to add to the admin list page for either of them a list filter for all pizzas which contain a certain topping / all toppings that are contained in a certain pizza? The built-in list_filter doesn't support m2m fields so I'm looking for som...

Django + WebKit = Broken pipe

I'm running the Django 1.2 development server and I get these Broken Pipe error messages whenever I load a page from it with Chrome or Safari. My co-worker is getting the error as well when he loads a page from his dev server. We don't have these errors when using Opera or Firefox. Traceback (most recent call last): File "/Library/Frame...

Python: how to execute generated code ?

Hello guys I have this code, and I would like to use the app parameter to generate the code instead of duplicating it. if app == 'map': try: from modulo.map.views import map return map(request, *args, **kwargs) except ImportError: pass elif app == 'schedule': try: from modulo.schedule.views ...

How to import classes into other classes within the same file in Python

I have the file below and it is part of a django project called projectmanager, this file is projectmanager/projects/models.py . Whenever I use the python interpreter to import a Project just to test the functionality i get a name error for line 8 that FileRepo() cannot be found. How Can I import these classes correctly? Ideally what I a...

Sending multiple http requests to Django from Android

Hi, I am developing a microblogging platform in which I need to populate the page with Post (user defined class with fields) obtained from the Django server using HttpGet. In the client side(Android) I am using GSON to parse the responses from server to the type Post. So I require that server should send Post's one by one so as to add...

How can I call model methods or properties from Django Admin?

Is there a natural way to display model methods or properties in the Django admin site? In my case I have base statistics for a character that are part of the model, but other things such as status effects which affect the total calculation for that statistic: class Character(models.Model): base_dexterity = models.IntegerField(defa...

How do I send this email in Python, opening files and stuff?

msg = EmailMessage(subject, body, from_email, [to_email]) msg.content_subtype = "html" msg.send() This is how I send an email in Django. But what if I want to open a text file and take into account all its line breaks and tabs. I want to take the body of the text file (with line breaks \n) and email it as text of the "body". ...