I have two models, Room and Image. Image is a generic model that can tack onto any other model. I want to give users a form to upload an image when they post information about a room. I've written code that works, but I'm afraid I've done it the hard way, and specifically in a way that violates DRY.
Was hoping someone who's a little ...
I've got a CMS that takes some dynamic content and renders it using a standard template. However I am now using template tags in the dynamic content itself so I have to do a render_to_string and then pass the results of that as a context variable to render_to_response. This seems wasteful.
What's a better way to do this?
...
i've got some weird characters in my database, which seem to mess up django when returning a page. I get this error come up:
TemplateSyntaxError at /search/legacy/
Caught an exception while rendering: Could not decode to UTF-8 column 'maker' with text 'i� G�r'
(the actual text is slightly different, but since it is a company name i'v...
In Django how can i return the total number of items (count) that are related to another model, e.g the way stackoverflow does a list of questions then on the side it shows the count on the answers related to that question.
This is easy if i get the questionid, i can return all answers related to that question but when am displaying th...
I'm new to the MDX/OLAP and I'm wondering if there is any ORM similar like Django ORM for Python that would support OLAP.
I'm a Python/Django developer and if there would be something that would have some level of integration with Django I would be much interested in learning more about it.
...
As the title suggests, I'm using Google App Engine and Django.
I have quite a bit of identical code across my templates and would like to reduce this by including template files. So, in my main application directory I have the python handler file, the main template, and the template I want to include in my main template.
I would have t...
I have Apache setup to serve requests for http://www.mysite.com from this directory:
/var/www/html/www.mysite.com
The Django site is in /var/www/html/www.mysite.com/mysite.
I get this error when I make a request for /mysite/app/foo:
(big stack trace)
AttributeError: 'module' object has no attribute 'common'
'myapp.common' is the fir...
I want to modify a few tiny details of Django's built-in django.contrib.auth module. Specifically, I want a different form that makes username an email field (and email an alternate email address. (I'd rather not modify auth any more than necessary -- a simple form change seems to be all that's needed.)
When I use autodiscover with a...
Is there a way to specify a Model in Django such that is ensures that pair of fields in unique in the table, in a way similar to the "unique=True" attribute for similar field?
Or do I need to check this constraint in the clean() method?
...
I was doing the tutorial from the book teach yourself django in 24 hours and in part1 hour 4 i got stuck on this error.
Traceback (most recent call last):
File "C:\Python25\lib\site-packages\django\core\servers\basehttp.py", line 278, in run
self.result = application(self.environ, self.start_response)
File "C:\Python25\lib\s...
Hi!
I have several objects in the database. Url to edit an object using the generic view looks like site.com/cases/edit/123/ where 123 is an id of the particular object. Consider the cases/url.py contents:
url(r'edit/(?P<object_id>\d{1,5})/$', update_object, { ... 'post_save_redirect': ???}, name = 'cases_edit'),
where update_object i...
I declare this:
#This file is using encoding:utf-8
...
class Buddy(models.Model):
name=models.CharField('ФИО',max_length=200)
...
... in models.py. manage.py syncdb works smoothly. However when I go to admin interface and try to add a new Buddy I catch a DjangoUnicodeDecodeError, which says: "'utf8' codec can't decode bytes in...
A bit more context, in case this question is too general: the uses I have in mind are running django and serving static content and name-based virtual hosting.
I am vaguely aware of the performance/resource tradeoffs between the different servers, but that is a secondary concern.
Anyone who has deployed all three in production?
...
How can i create simple group by query in trunk version of django?
I need something like
SELECT name
FROM mytable
GROUP BY name
actually what i want to do is simply get all entries with distinct names.
...
I'm a Windows user. I tried to install django-1.0.2 final through the command prompt and it kept giving me an error in line 70:
The error occured where u"SVN"... It couldn't get past that line.
Can anyone tell me what to do in order to be able to install django-1.0.2?
I'll be very grateful.
...
Hi!
Let's say I have the following model:
class Contest:
title = models.CharField( max_length = 200 )
description = models.TextField()
class Image:
title = models.CharField( max_length = 200 )
description = models.TextField()
contest = models.ForeignKey( Contest )
user = models.ForeignKey( User )
def score...
Am looking for a wiki formatting widget for my django application, just like the one am using to type this question in stackoverflow?
...
Hi all,
I am writing a fairly simple Django application where users can enter string queries. The application will the search through the database for this string.
Entry.objects.filter(headline__contains=query)
This query is pretty strait forward but not really helpful to someone who isn't 100% sure what they are looking for. So I ex...
Hi,
I have a model Foo which have a ForeignKey to the User model.
Later, I need to grab all the User's id and put then on a list
foos = Foo.objects.filter(...)
l = [ f.user.id for f in foos ]
But when I do that, django grabs the whole User instance from the DB instead of giving me just the numeric user's id, which exist in each Foo...
I want to be able to update a dynamic number of objects within a single form using Django and I'm wondering what the best way to do this would be. An example of a similar situation may help.
Model:
class Customer(Model.models):
name = models.CharField(max_length=100)
active = models.BooleanField()
Form (I know I'm mixing view...