django

How to URL encode this so I can pass it to Facebook Share?

This is the URL I want to share: http://mydomain.com/#url=http://stackoverflow.com Inside my site, I do this in Django so that everything will work: http://mydomain.com/#url={{external|urlencode}} However, when I pass it to Facebook Share, everything gets messed up. http://www.facebook.com/sharer.php?u=&lt;url to share>&t=<title o...

Evaluating Django Chained QuerySets Locally

Hello All: I am hoping someone can help me out with a quick question I have regarding chaining Django querysets. I am noticing a slow down because I am evaluating many data points in the database to create data trends. I was wondering if there was a way to have the chained filters evaluated locally instead of hitting the database. He...

Return template as string - Django

Hi All, I'm still not sure this is the correct way to go about this, maybe not, but I'll ask anyway. I'd like to re-write wordpress (justification: because I can) albeit more simply myself in Django and I'm looking to be able to configure elements in different ways on the page. So for example I might have: Blog models A site update me...

django: CheckboxMultiSelect problem with db queries

firstly sorry for my bad english there is a simple model Person. That contains just languages: LANGUAGE_LIS = ( (1, 'English'), (2, 'Turkish'), (3, 'Spanish') ) class Person(models.Model): languages = models.CharField(max_length=100, choices=LANGUAGE_LIST) #languages is multi value (CheckBoxSelectMultiple) and he...

Sumproduct using Django's aggregation

Question Is it possible using Django's aggregation capabilities to calculate a sumproduct? Background I am modeling an invoice, which can contain multiple items. The many-to-many relationship between the Invoice and Item models is handled through the InvoiceItem intermediary table. The total amount of the invoice—amount_invoiced—i...

How do I get django comments to join on auth_user

I'm using the django comments framework, and when I list the comments I want to include some of the information stored in auth_user. However, I find I need an extra query for each comment to get the user info. I tried using select_related() when I pull the comments, but this doesn't help. Is there a reason that it's not joining the aut...

Subclassed django models with integrated querysets

Like in this question, except I want to be able to have querysets that return a mixed body of objects: >>> Product.objects.all() [<SimpleProduct: ...>, <OtherProduct: ...>, <BlueProduct: ...>, ...] I figured out that I can't just set Product.Meta.abstract to true or otherwise just OR together querysets of differing objects. Fine, but...

ManyToManyField "table exist" error on syncdb

When I include a ModelToModelField to one of my models the following error is thrown. Traceback (most recent call last): File "manage.py", line 11, in <module> execute_manager(settings) File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 362, in execute_manager utility.execute() File "/Library/Pytho...

No matter what I do, django-admin.py is not found, even though it's in my path

I have added C:\Python26\Lib\site-packages\django\bin to my path, I have started a new cmd session in Windows 7, but when I try to do 'python django-admin.py ...' it says there is no file django-admin.py. When I type path, there is the full path to ...\django\bin. This is driving me nuts. Clearly it's there, but it's not working. Any su...

IntegrityError: foreign key violation upon delete

I have Order and Shipment model. Shipment has a foreign key to Order. class Order(...): ... class Shipment() order = m.ForeignKey('Order') ... Now in one of my views I want do delete order object along with all related objects. So I invoke order.delete(). I have Django 1.0.4, PostgreSQL 8.4 and I use transaction middleware...

Django Distinct on queryset in forms.py

Hi all, I try to get a list with distinct into the forms.py like this: forms.ModelMultipleChoiceField(queryset=Events.objects.values('hostname'), required=False).distinct() In the python shell this command works perfect, but when trying it in forms.py leaves me a blank form, so nothing appears. When i just do Events.objects.all() the ...

Django: ordering by backward related field property

Hello! I have two models related one-to-many: a Post and a Comment: class Post(models.Model): title = models.CharField(max_length=200); content = models.TextField(); class Comment(models.Model): post = models.ForeignKey('Post'); body = models.TextField(); date_added = models.DateTimeField(); I want to get...

"No module named slimmer.middleware"

Hello guys, I'm trying to setup blog engine django-mingus, but meet this obstacle: [Tue Mar 30 04:14:02 2010] [error] [client 192.168.12.161] mod_wsgi (pid=12908): Exception occurred processing WSGI script '/home/piv/srv/python-env/myblog/project/django-mingus/mingus/deploy/django.wsgi'. [Tue Mar 30 04:14:02 2010] [error] [client 192.16...

How to localize an app on Google App Engine?

What options are there for localizing an app on Google App Engine? How do you do it using Webapp, Django, web2py or [insert framework here]. 1. Readable URLs and entity key names Readable URLs are good for usability and search engine optimization (Stack Overflow is a good example on how to do it). On Google App Engine, key based querie...

Cache for everybody except staff members.

I have a django site where I want to stick an "admin bar" along the top of every non-admin page for staff members. It would contain useful things like page editing tools, etc. The problem comes from me using the @cache_page decorator on lots of pages. If a normal user hits a page, the cached version comes up without the admin bar (even ...

apache virtual host to work with django

My project is under: /home/projects/testing and I'm adding this to the buttom of my /etc/httpd/conf/httpd.conf file on Centos machine, but that is not working, <Location "/testing/"> SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE testing.settings PythonOption django.r...

Does SQLAlchemy have an equivalent of Django's get_or_create?

I want to get an object from the database if it already exists (based on provided parameters) or create it if it does not. Django's get_or_create does this. Is there an equivalent shortcut in SQLAlchemy? I'm currently writing it out explicitly like this: def get_or_create_instrument(session, serial_number): instrument = session.q...

Django i18n: how to not translate the admin site?

Hi, I have an application in several languages but I would like to keepthe admin site always in english. What is the best way to do this? Thanks in advance. ...

How to update the filename of a Django's FileField instance ?

Hello, Here a simple django model: class SomeModel(models.Model): title = models.CharField(max_length=100) video = models.FileField(upload_to='video') I would like to save any instance so that the video's file name would be a valid file name of the title. For example, in the admin interface, I load a new instance with title ...

FieldError when annotating over foreign keys

I have a models file that looks similar to the following: class WithDate(models.Model): addedDate = models.DateTimeField(auto_now_add=True) modifiedDate = models.DateTimeField(auto_now=True) class Meta: abstract = True class Match(WithDate): ... class MatchFilter(django_filters.FilterSet): class Meta: ...