Hello!
I've inherited an app created with Django. There is a problem with it: in admin interface, the page lists not all entities (videos), but some (16 of 25). I have no idea, what is this.
Then I run python manage.py shell, and there Video.objects.all(), there are all 25 objects (counted them using len and by iterating them with for ...
I have an issue where, when I log in to the Django admin site, I get a template syntax error in /Library/Python/2.6/site-packages/django/template/debug.py in render_node, line 81.
I can't find out how to solve this as it is part of Django, I didn't write the code and I have no idea how it works.
This did work fine up until a few days a...
I'm building a Q&A site where one can comment on questions and their answers.Its a threaded commenting system with ajax.
this is the javascript part:
function bindPostCommentHandler()
{
$('.commentFormWrapper form').submit(function() {
var current = $(this);
$.ajax({
type: "POST",
data: current....
Hello
I made some model classes with pets types: Parrot, Rabbit, Cat, Dog and i need make model
Shop, where one field will be related for few of this models. This field will show what sells in shop.
Can i make relation beetween one model object to few model classes?
If i can't, how i need change my scheme?
ex:
1 Shop1 [Parrot, Rabbit]...
A while back I made a Model class. I made several ModelForms for it and it worked beautifully.
I recently had to add another optional (blank=True, null=True) field to it so we can store some relationship data between Users. It's essentially a referral system.
The problem is adding this new field has meant the referral field shows up wh...
I have a dozen or so permission lookups on views that make sure users have the right permissions to do something on the system (ie make sure they're in the right group, if they can edit their profile, if they're group administrators, etc).
A check might look like this:
from django.contrib.auth.decorators import user_passes_test
test_c...
Hi all,
I want to be able to use extra variables on a custom 404 template.
#404.html
{{ extra_var }}
I have already tried:
#urls.py
from myproject.myapp import views
handler404 = views.handler404
#views.py
from django.template import RequestContext, loader
from django import http
def handler404(request):
extra_var = 'my_extra_v...
I am not really sure how to divide my Django projects into applications.
What things should I consider when laying out a Django project?
...
Hi,
I'm using a middleware to get the currently logged in user in my views and models. This helps me to for example return only the objects created or assigned to the logged-in user. Please follow this link to see which middleware that I use.
I call this middleware with:
get_current_user()
This worked fine till now. But now I experi...
Short description: given a queryset myQueryset, how do I select max("myfield") without actually retrieving all rows and doing max in python?
The best I can think of is max([r["myfield"] for r in myQueryset.values("myfield")]), which isn't very good if there are millions of rows.
Long description: Say I have two models in my Django app,...
I have an import script which runs a series of commands to get things from one Postgres DB to another, both running the same Django codebase. For the most part, it uses ./manage.py loaddata to copy over, but some objects require additional processing and I use Django's objects.create() method in a custom script to copy the data. When doi...
I don't know if this is expected behavior or not, but if I create a project with a single model with an ImageField field and upload a photo with the filename "árvórés", the uploaded file is saved with an incomprehensible filename(ascii, I presume). As a direct result, that photo becomes impossible to retrieve from the site.
Is this norm...
Hi there,
I'm not sure if decorators are the best way to do this, but I've removed the idea of using context processors and I'm not sure if a middleware is what I'd like.
My situation is as follows: We process sales and other data daily. Every month, we close the month off just like any other business. We do this on paper, but I would ...
This is my class:
class Account(models.Model):
name = models.CharField(max_length=255)
def __unicode__(self):
return '{0}'.format(self.name)
class Painting(models.Model):
account = models.ForeignKey(Account)
color = models.CharField(max_length=255)
def __unicode__(self):
return 'Account: {0} - Co...
Hi,
I want to learn ExtJs http://www.extjs.com/ in combination with Django (I know Django already .. a bit ;-) and I'm on the search of examples I can learn from.
I found already this post. Would be great if you post your links to examples here. Maybe we get a nice list of examplary implementations that help users to start with django ...
I can use jinj2 templates with django via render_to_response defined as below
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.http import HttpResponse
from django.template import TemplateDoesNotExist, Context
from django.utils import translation
from itertools import chain
from jinja...
I'm trying to find if two DateTimeFields are greater than 2 days difference in a template. Is this possible to do in a template?
...
heya,
I have a Django project, that has a "Address" model. This is used in several places - by a "User Profile" model, by a "Hospital" model, by an "Insitution" model etc.
I'm using Django's generic relations to allow each of these objects to create a foreign-key to Address.
However, this seems to cause some weirdness in the Django Ad...
I need to run a C++ Program from Django Framework. In a sense, I get inputs from UI in views.py . Once I have these inputs, I need to process the input using my C++ program and use those results. Is it possible ?
...
I need a regexp for a URL like:
/slug/#slug/slug/
I know it should be something like:
r'^(?P<slug1>[-\w]+)/#(?P<slug2>[-\w]+)/(?P<slug3>[-\w]+)/$'
But I am having problems with the character #
...