django

ImportError when trying to import from module directory. (Django)

Imagine a classic Django directory structure. INSTALLED_APPS contains an entry pointing to "myApp". I have models, views, etc. in that directory and it works fine. I've created a file called decorators.py in that directory. In one of the views, I'm trying to import some of those decorators but I'm getting: ImportError at / No module na...

Struts2 or Django for GAE and future scalability

Hi, I am developing location based service. FYI, the database will expand vastly as time and location are the variables. I am considering GAE for initial deployment. I am open for any of python or java based development. While calculating the scalability, I am getting confused. I never thought of scalability before as I haven't worked on...

Django: provide month and year number as parameter in a template for use in template tag

Hi, I am a Django Beginner. I found this Django snippet to show a simple calendar on my web page. The function needed 3 parameters that one can provide within the template as follows: {% load calendar_tag %} <div> <div>Calendar: </div> {% get_calendar for 10 2010 as calendar %} <table> <tr> <th>Mon</th> <th>Tue</th>...

In Django Admin how do I disable the Delete link

I've managed to disable the "Delete selected" action. Easy. But a user can still click on an item and then there's the red Delete link at the bottom. ...

Good ways to create step by step creation process in google app engine with django forms

I'm using AppEngine and django forms passing template_values and using base.html with {% extends "base.html" %} this works well in a testing environment when I have one big form for adding entities. I'm good in python, good with the datastore, but my html is weak/OLD I want to have a step by step process for creating datastore entities...

Django FileField encoding

I have a django model as follows: class ExportFile(BaseExportFile): created_timestamp = models.DateTimeField(auto_now=True, editable=False) data = models.FileField(upload_to='exports') and a view function that renders a template to create a csv file: def create_csv(request): context = Context({'data': MyModel.object...

Split a string into a list in django-templates

Basically, I have a colon delimited variable being passed into my template that I would like to loop through to display each individual element. I would like to be able to extract each of these names and then perform logic on them within my template. If I could use python, I would do something like (note: file_type is the variable I h...

Django sub-directory views and import all files from __init__.py

Technically not a django question, more a python question. In urls.py I've got the following: urlpatterns = patterns('locate.views', url(r'^', 'index.index'), ) And a directory structure like this: locate/ views/ __init__.py index.py # where there is "def index(request) : ...." What I would like to do is avoid...

Django: Accessing child class of an abstract model

I have several user profile models inherited from one base class like this: class BaseProfile(models.Model): user = models.ForeignKey(User) name = models.CharField(max_length=100) ... class Meta: abstract = True class DoctorProfile(BaseProfile): license_no = models.CharField(max_length=10) ... class Pha...

Django Paginator not working beyond first page

As mentioned in the title, my paginator doesn't show anything when I click to go to a page beyond the first. First, let me describe my page in general: Its function is to get a request input from the user specifying the period interval from which he wants to see a bunch of "call records" along with other filters (this is important). So e...

Django Template Tag inside JS script

I'm new to javascript so bear with me: I'm implementing Google Maps API and I'd like the first marker's InfoWindow to open when the template is first rendered but ONLY if certain condition is true. so, I have something like this: {% if project %} //the following is automatically open the infowindow of the FIRST marker in the array whe...

How to validate a Django Form field against a FK field

I am attempting to create a validation rule that passes an error if the (milestone)objects target_date is greater then the projects target_date. The issue is that none of the errors are being raised. For simplicities sake, models.py class Project(models.Model): target_date = models.DateField() class Milestone(models.Model): p...

Programmatically perform a nested GET request in Django

During the processing of a request in Django, I need to perform a nested request to the same application. Consider this example, where while processing the sendmail request, I attempt to make another request to the same server to obtain the content of an attachment (the body of the mail and a list of urls whose content to attach are prov...

django: templates how to fill a table of 3 items in a row

Hi, I want to fill a table with a list of results. But not sure how to tell the template that it's time to close current and start a new one, after 3 products was already displayed in current tr.... Would be happy if somebody could advice on it. I am running django 1.1.1 ...

Why is Loan undefined when type(self) works just fine?

The following code is being used by the admin to save a Loan object import uuid from django.db import models from django.contrib.auth.models import User from apps.partners.models import Agent # Create your models here. class Loan(models.Model): """ This is our local info about the loan from the LOS """ guid = models.CharField(...

limit_choice_to all objects of a particular model classe in a ForeignKey

Example class Base(): pass class A(Base) parent=models.Foreignkey("self", limit_choices_to=(all members of the B class) class B(Base) parent=models.Foreignkey("self", limit_choices_to=(all members of the A class) What would be the query syntax for limit_choices_to, to get only the objects of a certain class?) ...

Doubled POST requests instead of single

I have an edit page for my object. Because I've divided data in two tabs, I'm using jquery-ui. On the first tab (#core_data) I'm loading object's main data. Form is submited via Ajax : <form method="post" class="object_form" id="event-core-form" action="{% url edit_event_data event.id %}" enctype="multipart/form-data"> {{ form.as_p ...

How to add an annotation on distinct items?

I've got a query... packages = Package.objects.annotate(bid_count=Count('items__bids')) Which is supposed to give me a list of packages with the number of bids each. It works great if there's only one item in the package, but if there's more it double counts. Each package consists of 1 or more items. Each bid is placed on 1 or more i...

Django - How to save and continue editing when adding a new user from related model?

Is it possible to get a save and continue to edit functionality on the creation of a user when clicking on the "+" in a related model? for example here's a model: class Example(models.Model): user = model.ForeignKey(User) ... ... When in the Add/Edit admin screen for Example objects when a user wants/needs to add a new user t...

Django: Error: ImproperlyConfigured Module does not define a " " class

ImproperlyConfigured: Middleware module "report" does not define a "ReportMiddleware" class But I had defined this, but probably defined in wrong place, so where should I place this class file? ...