Django comes with a list of built-in middleware, but if one wants to use all (or most) of them, he has to work through tons of docs in order to get the right sorting in the settings.py file.
Is there an optimal default order of all built-in Django 1.1 middleware classes? I.e., something to copy'n'paste into settings.py:
MIDDLEWARE_CLAS...
I am in the process of deploying a new Django site to replace a current Wordpress blog. As I get it setup, I want to test everything in the domain's subdirectory before I switch things to the root and "go live". For example: http://example.com/django/
Editing my .htaccess file allows me to redirect things without a hitch (I can see th...
Hi,
I have a django website that is spilt depending on what user type you are, I need to redirect users that are not entitled to see certain aspects of the site,
in my template, I have
{% if user.get_profile.is_store %}
<!--DO SOME LOGIC-->
{%endif%}
how would I go about redirecting said store back to the index of the site?
==...
I can see the problem, I attached my code and error page.
In my template, I have:
{% if user.get_profile.is_store %}
<!--DO SOME LOGIC-->
{%endif%}
In my view, I have:
def downloads(request):
"""
Downloads page, a user facing page for the trade members to downloads POS etc
"""
if not authenticated_user(request):
return H...
This is a pretty simple Django question, but I can't find the answer in the Django docs, despite lots of hunting!
How do I check whether an object already exists, and only add it if it does not already exist?
Here's the code - I don't want to add the follow_role twice in the database if it already exists. How do I check first? Use get(...
I have a model not unlike the following:
class Bike(models.Model):
made_at = models.ForeignKey(Factory)
added_on = models.DateField(auto_add_now=True)
All users may work at a number of factories and therefore their user profiles all have a ManyToManyField to Factory.
Now I want to construct a ModelForm for Bike but I want the...
I am trying to make a Django website be a simple Windows executable. I've been told that py2exe does not work correctly, both due to Django using __import__, and to its attempting to dispatch manage.py in some obscure way. Is that the case? If so, is there an alternative tool that works better, or is there a way to work around the py2...
What I'm looking for is a QuerySet containing any objects not tagged.
The solution I've come up with so far looks overly complicated to me:
# Get all tags for model
tags = Location.tags.all().order_by('name')
# Get a list of tagged location id's
tag_list = tags.values_list('name', flat=True)
tag_names = ', '.join(tag_list)
tagged_loca...
Hi!
I have an app that's about presenting fictional simplified cities.
Please consider the following Django models:
class City(models.Model):
name = models.CharField(...)
...
TYPEGROUP_CHOICES = (
(1, 'basic'),
(2, 'extra'),
)
class BldgType(models.Model):
name = models.CharField(...)
group = models.IntegerFi...
I have a Posting app which has, as an inline, FKs to a Gallery object. The idea being that while making a Posting, a user can click to add a Gallery object to the Posting. For that purpose, I am using a raw_id_field field to pop up the window for Gallery selection.
My problem is that I don't want users to have access to modify or add Ga...
On my Django site I would like users to communicate with each other in several ways:
Forum
Private messages
Chat with rooms and saved history
Could you suggest me ready solutions for this? Especially for chat.
Also, is it possible to integrate Google Wave in Django?
...
I have a simple webapp in Django for an iPhone app.
I want to prompt the user to review our product, but just once. I then don't want to show that prompt again.
So would the best practise way of implementing this to be to add a new entry to the user profile model with a bolean field: "reviewed" - and then set that flag when the user com...
I'm trying to display a simple ModelForm for a user's profile and allow the user to update it. The problem here is that my logic is somehow flawed, and after a successful form.save() call, the old values show on the page. It isn't until a refresh that the appropriate value is shown. What is wrong here?
@login_required
def user_profile(r...
I have a requirement where one user creates an 'instance' of an object via a ModelForm. Another user of a different group has access to read all of the fields of the form, but has to update only one field. Think of a student who creates an exam object. Then a teach pulls up the exam and just needs to put in a grade, the rest of the exam ...
I have a model defined like this:
class UserDetail(models.Model):
user = models.ForeignKey(User, db_index=True, unique=True, related_name='details')
favourites = models.ManyToManyField(Article, related_name='favourited_by', blank=True)
And I'm trying to do something like this:
article = get_object_or_404(Article, pk=id)
reque...
Does anyone have a good tute/example of writing good tests for views? Most of the stuff I've been finding was from mid 2008 which is only a little helpful.
...
Edited :-) Hopefully a bit clearer now.
The logic is of the model is:
A Building has many Rooms
A Room may be inside another Room (a closet, for instance--ForeignKey on 'self')
A Room can only in inside of another Room in the same building (this is the tricky part)
Here's the code I have:
#spaces/models.py
from django.db i...
I have a Django model:
class Foo(models.Model):
name = models.CharField(unique=True)
attribute1 = models.FloatField(null=True, blank=True)
attribute2 = models.FloatField(null=True, blank=True)
attribute3 = models.BooleanField(null=True, blank=True)
attribute4 = models.CharField(null=True, blank=True)
inherit = mo...
I've managed to get Django Forms to dynamically generate additional fields based on the relationship between a specific instance (eg. 'product type') and another model (eg. 'product attributes') eg. products have common attributes like weight and price but a book has a page count and a computer has specs.
I'd like to be able to do the s...
hi folks,
I having trouble serving Django's static admin files on webfaction.
Here's how I'm currently set up:
I've created a 'Symbolic link to
static-only app', and provided the
link to Django admin files in 'extra
info':
/home/myusername/webapps/mydjangoapp/lib/python2.5/django/contrib/admin/media
(cd'ing into that directory works
...