Edit: I have now discovered that the status code is returned correctly, it just isn't recorded correctly in Apache's access.log. Title amended. This is still a problem. Any ideas? Original question follows.
Hi all.
I run the following stack: Django(svn) on WSGI on FastCGI on Apache on Dreamhost. Every page served by Django returns HTTP...
To extend the User object with custom fields, the Django docs recommend using UserProfiles. However, according to this answer to a question about this from a year or so back:
extending django.contrib.auth.models.User also works better now -- ever since the refactoring of Django's inheritance code in the models API.
And articles suc...
I have to insert 2 forms in the same page:
1) Registration form
2) Login form
.
So if I use this in the views.py:
if request.method == 'POST':
form = registrationForm(request.POST)
if form.is_valid():
form.save()
return render_to_response('template.html', {
'form': form,
})
I...
I am in a process of designing a client for a REST-ful web-service.
What is the best way to go about representing the remote resource locally in my django application?
For example if the API exposes resources such as:
List of Cars
Car Detail
Car Search
Dealership summary
So far I have thought of two different approaches to take:
...
Here is a simple model:
class TakingCourse(models.Model):
course = models.ForeignKey(Course)
term = models.ForeignKey(Term)
Instead of Django creating a default primary key, I would like to use both course and term as the primary key - taken together, they uniquely identify a tuple. Is this allowed by Django?
On a related not...
i am trying to print a list of all the Conferences and for each conference, print its 3 Speakers.
in my template i have:
{% if conferences %}
<ul>
{% for conference in conferences %}
<li>{{ conference.date }}</li>
{% for speakers in conference.speakers %}
<li>{{ co...
Hi all,
I'm trying to get an abstract model working in Django and I hit a brick wall trying to set the related_name per the recommendation here: http://docs.djangoproject.com/en/dev/topics/db/models/#be-careful-with-related-name
This is what my abstract model looks like:
class CommonModel(models.Model):
created_on = models.DateTi...
I have a site with users who can take terms at University:
class Term(models.Model):
school = models.ForeignKey(School)
name = models.CharField(max_length=200)
isPrimaryTerm = models.BooleanField()
date = models.DateField()
class MyUser(models.Model):
user = models.ForeignKey(User, unique=True)
takingReqSets = m...
I am developing a Django project with PyDev in Eclipse. For a while, PyDev's Django Shell worked great. Now, it doesn't:
>>> import sys; print('%s %s' % (sys.executable or sys.platform, sys.version))
C:\Python26\python.exe 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)]
>>>
>>> from django.core import management;i...
How do I set the language code inside a view (in django)?
I'm sending a HttpResponse that contains a python-date.strftime("%A").
%A is the day (e.g. 'Monday'), but I want to get the day in Swedish instead of English.
...
Hello!
I have a situation where we are trying to autofill some form data on the second page of a signup and I was wondering if there's a way to bypass the entire form validation when we pass in only a couple of fields?
so we have something like
form = NewForm(request.POST)
Where request.POST only contains some of the fields in NewFor...
I have the following models
class Database(models.Model):
user = models.ForeignKey(User)
name = models.CharField(max_length=100)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
class DatabaseUser(models.Model):
user = models.ForeignKey(User)
name = models.CharFiel...
Hi! Im programming with django and i need to serialize an object to a string, but i need to get the string \/ serialized.
An example:
simplejson.dumps({'id' : 'root\/leaf'})
I need an output like this:
'{"id": "root\/leaf"}'
but i get this:
'{"id": "root\\\\leaf"}'
Thank you!!
PD: Sorry for my english :-P
...
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 2: ordinal not in range(128)
I changed my database default to be utf-8, and not "latin"....but this error still occurs. why?
This is in my.cnf. Am I doing this wrong? I just want EVERYTHING TO BE UTF-8.
init_connect='SET collation_connection = utf8_general_c...
It's easy to serialize models in an iterable:
def _toJSON(models):
return serializers.serialize("json", models, ensure_ascii=False)
What about when I have something more complicated:
[
(Model_A_1, [Model_B_1, Model_B_2, Model_B_3]),
(Model_A_2, [Model_B_3, Model_B_4, Model_B_5, Model_B_59]),
(Model_A_3, [Model_B_6, Model_B_7]),
]...
Let's say that I have a Person who runs an inventory system. Each Person has some Cars, and each Car has a very large number of Parts (thousands, let's say).
A Person, Bob, uses a Django form to create a Car. Now, Bob goes to create some Parts. It is only at the form level that Django knows that the Parts belong to some specific Car,...
i have one web application, with postgresql as DB, evrything is fine..now trying to implement one security feature..that my db should be updated or del or any thing has to done through my application only...and admin also...i.e sort to protecting the db..no one change it back end..and through some application....i need some ideas
...
In Django I calculate the breadcrumb (a list of fathers) for an geographical object. Since it is not going to change very often, I am thinking of pre calculating it once the object is saved or initialized.
1.) What would be better? Which solution would have a better performance? To calculate it at _init_ or to calculate it when the obje...
I have a webpage that displays data based on a default date. The user can then change their view of the data by slecting a date with a date picker and clicking a submit button. I already have a variable set so that if no date is chosen, a default date is used.... so what's the problem? The problem comes if the user trys to type in the...
Hi, I have server with django on it, this server runs some manage.py commands and update database. Now I need to move some of this tasks to different servers. I don't want to allow remote db access and need some tool\lib to be able to start task on remote servers by main server's command and update tasks code/add new tasks. I have ssh ac...