What's the best way to implement the following:
### models.py
>>> from django.db import models
>>> from django.contrib.auth.models import User
# Create the client class.
>>> class Client(models.Model):
... user = models.OntToOneField(User)
... zip = ***???***()
### forms.py
>>> from django.forms import ModelForm
# Create the fo...
I'd like to use the following form class in a modelformset. It takes a maps parameter and customizes the form fields accordingly.
class MyModelForm(forms.ModelForm):
def __init__(self, maps, *args, **kwargs):
super(MyModelForm, self).__init__(*args, **kwargs)
#customize fields here
class Meta:
model = My...
Hello,
The background is that I've got a celery distributed job server configured with a Django view that returns the status of a running job in JSON. The job server is located at celeryserver.mydomain.com and the page I'm executing the jQuery from is www.mydomain.com so I shouldn't need to consider JSONP for this should I, as the req...
So i've just finished the google app engine greetings tutorial. All well so far. I then decided to try and add a new datastore model and then set it in the existing handler. I added a 2nd content field called "content2" and then tried to set it in the handler Guestbook(), but it keeps borking out. I'm sure it will be the silliest error, ...
I'm using a user profile model with a ForeignKey to the User, authenticated by django.contrib.auth.
The same auth module is of course used for the admin interface, so if a superuser/staff member is logged in to the admin interface, and enters the main site, the site will accept session cookie and authenticate him. This creates a proble...
I'm using Django 1.1 rc1 and Apache 2.2.8 on Ubuntu with mod_wsgi 1.3.1 + Python 2.5.2.
Everything worked fine with Django's internal testing web server, but after migrating to Apache mod_wsgi, all urls like /admin/appname/modelname/ began not to work. They shows 404 not found errors with the following log:
...
^admin/ ^$
^admin/ ^logo...
Hi,How can i make user to downlaoad a excel from the django app.i HAVE A MODEL WHICH gives the report.Now i want a option from user can download the file in excel form.ANy Solution
...
In trying to save as much time as possible in my development and make as many of my apps as reusable as possible, I have run into a bit of a roadblock. In one site I have a blog app and a news app, which are largely identical, and obviously it would be easier if I could make a single app and extend it where necessary, and then have it fu...
As the title says, in a multiple ethernet interfaces with multiple IP environment, the default Django test server is not attached to the network that I can access from my PC. Is there any way to specify the interface which Django test server should use?
-- Added --
The network configuration is here.
I'm connecting to the machine via 14...
Is there possibility to narrow context for include.
For example, I have "for" tag that gets from posts array - one post. Than I wonna put this post inside "include" tag to render in more detail context. Is there custom tags for this?
...
How can I make the development server from django running permanent? So that it does't stop when i quit the shell.
Thanks
...
Hi,
this question is about the last example on Custom managers and model inheritance.
I want to be able to do something similar to the following:
class ExtraManagerModel(models.Model):
# OtherManager class supplied by argument shall be set as manager here
class Meta:
abstract = True
class ChildC(AbstractBase, ExtraManage...
I'm having trouble with a custom tag in Django.
Is there any way I can see a list of what custom tags have been defined and are currently registered?
...
I'm about to make a dynamic website in Django so that user can change the template the website is based upon....for new users, they'll have to choose a template they like from a menu, after which this is stored in a cookie for future reference. I however don't know how to do this....any ideas.
...
My Django site recently started throwing errors from my caching code and I can't figure out why...
I call:
from django.core.cache import cache
cache.set('blogentry', some_value)
And the error thrown by Django is:
TransactionManagementError: This code isn't under transaction management
But looking at the PostgreSQL database logs, i...
I'm trying to set up my uploads so that if user joe uploads a file it goes to MEDIA_ROOT/joe as opposed to having everyone's files go to MEDIA_ROOT. The problem is I don't know how to define this in the model. Here is how it currently looks:
class Content(models.Model):
name = models.CharField(max_length=200)
user = models.Forei...
This is a query that totals up every players game results from a game and displays the players who match the conditions.
select *,
(kills / deaths) as killdeathratio,
(totgames - wins) as losses
from (select gp.name as name,
gp.gameid as gameid,
...
How can you perform complex sorting on an object before passing it to the template? For example, here is my view:
@login_required
def overview(request):
physicians = PhysicianGroup.objects.get(pk=physician_group).physicians
for physician in physicians.all():
physician.service_patients.order_by('bed__room__unit', 'bed__room__orde...
I moved a site to a mediatemple server using python 2.3, now imageField won't work in the admin. Upon saving, validation gives the "not valid image" error.
checked:
-media_root and media_url are correct
-pil contains jpg support
-upload folders set to 775
-image is not corrupted
Ideas? Thanks.
...
I'm building a website using Django + Apache and Nginx to serve my static content. My site's index does not require any backend Django coding, so what would I need to change in nginx.conf to send requests for location / { } to some index.html in my static-content, while still allowing my urls.py to handle patterns appropriately?
upstrea...