I was just looking over EveryBlock's source code and I noticed this code in the alerts/models.py code:
def _get_user(self):
if not hasattr(self, '_user_cache'):
from ebpub.accounts.models import User
try:
self._user_cache = User.objects.get(id=self.user_id)
except User.DoesNotExist:
...
Hi!
I am trying to create simple flex application, which uses django as a back-end part. Have a question:
Usually when I run my application Flex Builder creates a file in a directory on my local PC and then opens a browser and points to it. Everything was fine, but when I decided to link django server to flex applications via xml data ...
Is there a way to simplify this working code?
This code gets for an object all the different vote types, there are like 20 possible, and counts each type.
I prefer not to write raw sql but use the orm. It is a little bit more tricky because I use generic foreign key in the model.
def get_object_votes(self, obj):
"""
Get a dicti...
Hello DJango warriors !
I am building a small app as a service in django and now is the time to integrate it on some clients PHP web app.
Our client A from domain www.a.com handles his own authentication for his users and probably use cookies for sessions.
How could i make logged in users from his domain also logged in on my Django ap...
Dear all,
I'm trying to get my head around Django ORM. I've been reading django.db.models.base.py source code but still could understand how does the Model.objects attributes in our Model object gets defined. Does anybody know how does django adds that objects attribute into our Model object?
Thanks in advance
...
I'd like to know how can I sort values in the Django admin dropdowns. For example, I have a model called Article with a foreign key pointing to the Users model, smth like:
class Article(models.Model):
title = models.CharField(_('Title'), max_length=200)
slug = models.SlugField(_('Slug'), unique_for_date='pub...
Hi Guys ,
I was trying to setup django . I do have Django-1.1-alpha-1. I was trying to make the documentation which is located at Django-1.1-alpha-1/doc using make utility.
But I am getting some error saying
> C:\django\Django-1.1-alpha-1\docs>C:\cygwin\bin\make.exe html
mkdir -p _build/html _build/doctrees
sphinx-build -b html -d ...
I have a django project that I have been working on as a solo developer, and have been using TortoiseSVN to keep the code managed in a repository on a work server. I work on this on a local installation of django etc.
There is now a second person who will be working on this project, and the possibility of working on some other PCs.
Now...
I'm trying to create a REST web service that exposes the following Django model:
class Person(models.Model):
uid = models.AutoField(primary_key=True)
name = models.CharField(max_length=40)
latitude = models.CharField(max_length=20)
longitude = models.CharField(max_length=20)
speed = models.CharField(max_length=10)
...
(Disclaimer: I asked this question yesterday on HN http://bit.ly/m6onk. While responses were good, there was a notable lack of technical discussion and more of a "you should use rails because that's what you know". Since Joel and Jeff state clearly they don't mind reposts of questions from other sites...and since I really enjoy the answe...
I am new to both Django and Rails. I am thinking of developing an Web 2.0 style application and is planning to expose Restful services, which my UI tier would call to make CRUD operations (Something similar to ADO.NET Data services)
I am yet to decide on the platforms and is looking for some advice on which one to side develop on?
I am...
Has anyone used SQLAlchemy in addition to Django's ORM?
I'd like to use Django's ORM for object manipulation and SQLalchemy for complex queries (like those that require left outer joins).
Is it possible?
Note: I'm aware about django-sqlalchemy but the project doesn't seem to be production ready.
...
So I am trying to use the Cheetah templating engine in conjunction with the Django web framework, and that is actually working fine. I did some simple tests with that and I was able to render pages and whatnot.
However, problems arise whenever doing anything other than using very simple variable/attribute/methods in the Cheetah templat...
When using localized list of "choices" for a model field, the admin doesn't show the translated values in the list view.
Short example:
from django.utils.translation import ugettext_lazy as _
class OrderStates:
STATES = (
(STATE_NEW, _("New")),
(STATE_CANCELLED, _("Cancelled")), )
class Order(models.Model):
st...
I am looking for an easy to use CMS that can be used to host a multilingual website with photo galleries and few forms.
I am open to php/python excluding wordpress/joomla/drupal.
...
So I have a class, specifically, this:
class ProductVariantForm_PRE(ModelForm):
class Meta:
model = ProductVariant
exclude = ("productowner","status")
def clean_meta(self):
if len(self.cleaned_data['meta']) == 0:
raise forms.ValidationError(_(u'You have to select at least 1 meta attribute.'))...
I have a simple django app to simulate a stock market, users come in and buy/sell. When they choose to trade,
the market price is read, and
based on the buy/sell order the market price is increased/decreased.
I'm not sure how this works in django, but is there a way to make the view atomic? i.e. I'm concerned that user A's actions m...
I want users on the site to be able to download files whose paths are obscured so they cannot be directly downloaded.
For instance, I'd like the URL to be something like this, "http://example.com/download/?f=somefile.txt
And on the server, I know that all downloadable files reside in a folder "/home/user/files/".
Is there a way to mak...
I need to have a status message that is set while processing an initial request appear after a redirect occurs. A pretty normal thing to need to do but I'm unclear how to use the session object to do this in Django. I know there's a plugin someone made: http://wiki.github.com/danielfm/django-flash
Is that the recommended way of handli...
In a view in django I use random.random(). How often do I have to call random.seed()?
One time for every request?
One time for every season?
One time while the webserver is running?
...