My models:
class Contact(models.Model):
first_name = models.CharField(_("First name"), max_length=30, )
last_name = models.CharField(_("Last name"), max_length=30, )
email = models.EmailField(_("Email"), blank=True, max_length=75)
class PhoneNumber(models.Model):
contact = models.ForeignKey(Contact)
phone = models.C...
How can I make default value for a field to be taken from existing objects of a model?
I tried these and it didn't worked:
1)
class ModelA(models.Model):
fieldA = models.CharField(default=self.get_previous())
def get_previous(self):
return ModelA.objects.all()[0].fieldA
NameError: name 'self' is not defined
2)
cla...
I'm having an issue with setting up a Django website which uses the Django comments framework on my server. The site runs fine when run locally (using manage.py runserver) but when pushed live I'm getting the error:
ImproperlyConfigured at /
The COMMENTS_APP setting refers to a non-existing package.
My server is an apache/mod_wsgi setu...
I am trying to understand how Django and Appengine work together?
First, question: Is this a good team?
Experience, what is possible and what not, would be great.
I also read some modules like auth, admin wont work.
But the article is rather old, so maybe there is an update.
And in that tutorial one has to import bforms.
What is tha...
Hey guys,
I'm doing a multi-player text based card game for fun in Django where each card allows each player to make some standard actions (Draw more cards, get gold, get points etc.) and maybe some other abilities (Like destroy a card from an opponents hand, give an opponent minus points and many more).
I have created a Card class:
c...
I am testing my application and I am running into an issue and I'm not sure why. I'm loading fixtures for my tests and the fixtures have foreign keys that rely on each other. They must be loaded in a certain order or it won't work.
The fixtures I'm loading are:
["test_company_data", "test_rate_index", 'test_rate_description']
Company ...
I would like to be able to abort a task that is running from a Celery queue (using rabbitMQ). I call the task using
task_id = AsyncBoot.apply_async(args=[name], name=name, connect_timeout=3)
where AsyncBoot is a defined task.
I can get the task ID (assuming that is the long string that apply_async returns) and store it in a database...
Using a variety of resources, I've come up with the following django middleware to prevent browser caching for authenticated users:
class NoBrowserCachingMiddleware:
def add_to_header(self, response, key, value):
if response.has_header(key):
values = re.split(r'\s*,\s*', response[key])
if not value in values:
...
Hi,
I have a strange behaviour on my Django/PostgreSQL system.
After saving a model object the primary key is none although it's an AutoField and the id is correctly saved in the database.
The following script passage returns None for the id:
a = SomModelClass()
a.someattribute = 'xyz'
a.save()
a.someattribute
>>> 'xyz'
a.id
>>> None...
KeyError when trying to save model instance.
It has to react on post_save signal than save instance...
Code:
from django.db.models.signals import post_save
class PlaylistEntry(models.Model):
playlist=models.ForeignKey(Playlist)
media=models.ForeignKey(Media)
order=models.PositiveIntegerField(default=9000000, editable=False...
Hi,
I am trying to use Django in Eclipse, but I have no idea how to import Django in Pydev project lists. The 'New Project' just has 'Pydev projec'.
Some help please
Thank you
...
Hey,
I have just updated to 1.4.2 and now everything that has worked before does not. And I cant figure out why.
var data = {
'what': 'post',
'type': $(this).attr('class'),
'id': $(this).next('input').val()
}
$.post(
'/utils/ajax/',
data,
function(response) {
alert(response.result);
}, 'json'
);
It...
I`m learning programming languages. And I decide that I need to lear a new web framework. I have 2 candidates: Django or ASP.NET MVC 2.
Can you say me the difference between them and what is so interesting?
...
I have a view function:
@login_required
def myviev():
do something
responce something
How can I specify the exact url for this view function to be redirected?
...
Consider that I include namespaced reusable application:
urlpatterns = patterns('',
# ella urls
url('^ella/', include('ella.core.urls', namespace="ella")),
)
Now, the Ella applications has urls like that:
urlpatterns = patterns( '',
url( r'^(?P<category>[a-z0-9-/]+)/$', category_detail, name="category_detail" ),
# obj...
I'm using django-nose to test our Django projects. It is common to split large test suites inside an application in Django like this:
myapp/
__init__.py
models.py
tests/
__init__.py
test_views.py
test_models.py
views.py
tests/__init__.py would look like this:
from test_views import *
from test_models import *
Si...
Hi,
What URL should i give facebook to get a FACEBOOK_API_KEY if i'm using facebook connect with the django development server? I understand I need to edit my local host, but i'm not sure with what.
Thanks,
David
...
Hi there,
I have a problem with Django settings.
My app runs with app-engine-patch.
I added a script that runs without django, and is reached directly via the app.yaml handlers.
I then get this error:
File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/conf/__init__.py", line 53, in _import_settings
raise Envi...
Hi,
I tried hard to configure mod_wsgi for an pinax project. I followed the exact instructions from the site (pinaxproject.org), unfortunately, I always got the following error:
[Thu Aug 26 17:32:46 2010] [error] [client 173.48.119.55] (13)Permission denied: mod_wsgi (pid=26749): Unable to connect to WSGI daemon process 'www.mysiste.c...
I'm building a django site with the admin site enabled on the backend. I want to change the names shown on the headers for the various model fields without actually changing the name of the fields. Is there an easy way to do this? I've browsed the django site and can't seem to locate this information.
Anyone know if this can be done and...