I have a many to many relationship between 2 tables Users an Domains.
I have defined this relationship in the Domains class.
So in the admin interface I see the Users when I am viewing Domains.
But I do not see Domains when I am viewing Users.
How can I achieve this.
...
return sum(jobrecord.get_cost() or 0
for jobrecord in self.project.jobrecord_set.filter(
date__lte=date,
date__gte=self.start_date) or 0)
...
What is the "django-way" of specifying channel image in rss feed? I can do it manually by rolling my own xml, but was looking for a proper way of doing it.
Edit
dobrych's solution is not quite applicable here because I was asking specifically about RSS not Atom feeds
...
I'm trying to use the admin datepicker in my own django forms.
Roughly following the discussion here : http://www.mail-archive.com/[email protected]/msg72138.html
I've
a) In my forms.py included the line
from django.contrib.admin import widgets
b) and used the widget like this :
date = forms.DateTimeField(widget=widget...
Given a set of typical models:
# Application A
from django.db import models
class TypicalModelA(models.Model):
the_date = models.DateField()
# Application B
from django.db import models
class TypicalModelB(models.Model):
another_date = models.DateField()
...
How might one change the default widget for all DateFields to a cu...
I create a modelForm with instance to existing model (Book). I am not able to update the Books record. Adding a new record is fine but when I attempt to update, it appears to be unable to find the publisher (which is a foreign key). Error is "No Publisher matches the given query."
models.py
class Publisher(models.Model):
name = models...
I have this view in my app:
def context_detail(request, context_id):
c = get_object_or_404(Context, pk=context_id)
scs = SherdCount.objects.filter(assemblage__context=c).exclude(count__isnull=True)
total = sum(sc.count for sc in scs)
table = []
forms = []
for a in c.assemblage_set.all():
for sc in a.sherdcount_set.all():
for...
I have a flag attached to my "UserProfile" record for logged in users that lets me know whether the user is enabled for "new features" on my site. I want to be able to check this django template variable in all of my templates to hide/show new features
I already used:
{% if user.is_authenticated %}
To check for logged in users, I ...
I have an existing django web app that is in use. I have to radically migrate one key model in my design to a completely new design, but I want to cache all of the existing data for that model and migrate them to the new records in production when ready to deploy.
I can afford to bring my website down for a few hours one night and do w...
How do I pass a list of Qs to filter for OR lookups? Something like:
q_list = [Q(xyz__isnull=True), Q(x__startswith='x')]?
Without a list I would do:
Model.objects.filter(Q(xyz__isnull=True) | Q(x__startswith='x'))
...
This is a follow-up on How do you change the default widget for all Django date fields in a ModelForm?.
Suppose you have a very large number of models (e.g. A-ZZZ) that is growing with the input of other developers that are beyond your control, and you want to change the way all date fields are entered (i.e. by using jQueryUI). What's t...
I've got a Django-based site that allows users to register (but requires an admin to approve the account before they can view certain parts of the site). I'm basing it off of django.contrib.auth. I require users to register with an email address from a certain domain name, so I've overridden the UserCreationForm's save() and clean_email(...
On my django 0.96 admin page, there was a "Documentation" link which led to all kinds of nice introspection features. After installing django 1.02, I no longer have this link. How can I get it back?
...
Have 2 tables Domain and Group having one to many relationship.
These tables have many to many relationship with User table
On the User admin interface I am rendering the Group and Domain as CheckboxSelectMultiple
widgets.
Is it possible to present this in a table form with 2 columns: Domain in one column and the list of groups belong...
Has anyone got connection pooling working with Django, SQLAlchemy, and MySQL?
I used this tutorial (http://node.to/wordpress/2008/09/30/another-database-connection-pool-solution-for-django-mysql/) which worked great but the issue I'm having is whenever I bring back a time field it is being converted to a timedelta since the Django-speci...
I'm wondering is there any open-source solution for web-book creation like "The Django Book" has?
It has a really usable web interface, comments system (with comments targeted on certain peace of text), pdf nightly auto-generation, with whole content pulled from repo...
...
I have a pretty simple question. I want to make some date-based generic views on a Django site, but I also want to paginate them. According to the documentation the object_list view has page and paginate_by arguments, but the archive_month view does not. What's the "right" way to do it?
...
My general website is in Django.
I want to create a subpage in which the following game happens:
A word that gets loaded from the database gets shown for 100ms.
Afterwards the user has to write out the word and is told whether his answer is right or wrong.
This game shall repeat itself ten times while the user is one the page and I want ...
I'm trying to serve static files for download in a django application, I figured that I'd put the static files in /media/files and have Apache set the content-type header to application/octet-stream (the files to download are going to be word files but I'll work out the details later).
To do this I activated mod_headers and then in the ...
I am using this file storage engine to store files to Amazon S3 when they are uploaded:
http://code.welldev.org/django-storages/wiki/Home
It takes quite a long time to upload because the file must first be uploaded from client to web server, and then web server to Amazon S3 before a response is returned to the client.
I would like to ...