django

Django: Conflict Between Live & Staging Sites on Same Server

I've recently pushed a Django app live. We built the app in a staging subdomain on the server. When I went live, I copied the files of the staging subdomain to the main site, created a staging database and pointed the old staging site at the new staging database (leaving the new live site pointed at the original database). This is on mod...

How do I run Django and PHP together on one Apache server?

I can currently run either Django through mod_wsgi or PHP on my Apache server. My Django projects run at: http://localhost and source is at C:/django_proj My PHP projects run at: http://php.localhost and source is at C:/web If I turn both on, php.localhost and localhost go to the Django project. I've already set them up through Apache...

bug in "django-admin.py makemessages" or xgettext call? -> "warning: unterminated string"

django-admin.py makemessages dies with errors "warning: unterminated string" on cases where really long strings are wrapped: string = "some text \ more text\ and even more" These strings don't even need to be translated - e.g. sql query strings. The problem goes away when I concatenate the string, but the result l...

dynamically populating fields in a formset

I have two models that looks like this: class RouteBase(models.Model): base = models.ForeignKey("Base") route = models.ForeignKey("Route") sequence = models.IntegerField() class Route(models.Model): bases = models.ManyToManyField("Base", through="RouteBase", blank=True) description = models.TextField(blank=True) #and a few oth...

Django - argument of type 'WSGIRequest' is not iterable

How do you fix the following Django bug when working with forms? TypeError at /url/ argument of type 'WSGIRequest' is not iterable ...

Add functionality to Django FlatPages without changing the original Django App

Hello people, I would like to add a field to the Django FlatPage database model, but I do not really know how to extend this without editing the original application. What I want to do is to add the following field to the model: from django.db import models from django.contrib.flatpages.models import FlatPage as FlatPageOld class Fl...

Complete CMS (or framework for CMS) with i18n support

We are looking for a way to publish articles in different languages, including differences in writing direction (RTL/LTR) and of course character sets. The maintainer of the current site works with Mambo/Joomla, but has already found severe restrictions in terms of extensibility. A similar question has already been asked, but I will add...

Linking to the django admin site

Very basic question, but I'm having trouble tracking down the answer on the web. I have a template, which I want to link to the django admin site (i.e. localhost:8000/admin). What is the code for this? I'm imagining something like <a href="{% url admin.site.root %}">link to admin panel</a> However, when I try the above snippet I get:...

Django admin -- restricting access by user

I was wondering if the django admin page can be used for external users. Let's say that I have these models: class Publisher(models.Model): admin_user = models.ForeignKey(Admin.User) .. class Publication(models.Model): publisher = models.ForeignKey(Publisher) .. I'm not exactly sure what admin_user would be -- perhaps it cou...

Deploying Django

When finding web hosting for Rails apps, the hoster must have support for ruby on rails -- that is evident. What about hosting for Django? What support does the hoster need to provide? Python, or more than just Python? This might seem like an obvious question, but I'm new to web development frameworks so I must ask :) ...

[Django/Python] Why does mass importing not work but importing definition individually works?

Hi. So I just met a strange so-called bug. Because this work on my other .py files, but just on this file it suddenly stopped working. from tuttobelo.management.models import * The above used to work, but it stopped working all of a sudden, and I had to replace it with the bottom. from tuttobelo.management.models import Preferences,...

working with django and sqlalchemy but backend mysql

i am working with python django framework but in model part is sqlalchemy and back end data base is mysql how i will configure them??? ...

Django media URLs in CSS files

In django templates, it's common to do the following: <img src="{{ MEDIA_URL }}/img/someImage.jpg"> How would you accomplish this in a CSS file which is not served as a template? .someClass { /* can't do this this */ background: url("{{ MEDIA_URL }}/img/someImage.jpg"); /* either this */ background: url("http:...

Django: Is there a better way to bold the current page link

I have a base.html template that contains a list of links. Example: <div id="sidebar1"> <ul> <li><a href="/" title="">Index</a></li> <li><a href="/stuff/" title="" class="current">Stuff</a></li> <li><a href="/about/" title="">About Me</a></li> <li><a href="/contact/" title="">Contact Me</a></l...

How can I put a block of dynamically generated content into a django template?

I want to include things like twitter status, or delicious tags, in my django templates. These things are dynamic, yet regular. How would this be done? ...

How to use primary key id in the name of uploaded file/image?

I need to generate name of uploaded image with mask images/{{ uploaded_image.id }}.jpg I think the best way to do this is *FileField.upload_to* property, but it is written Here: In most cases, this object will not have been saved to the database yet, so if it uses the default AutoField, it might not yet have a value for its prima...

Django - alternative to subclassing User?

I am using the standard User model (django.contrib.auth) which comes with Django. I have made some of my own models in a Django application and created a relationship between like this: from django.db import models from django.contrib.auth.models import User class GroupMembership(models.Model): user = models.ForeignKey(User, null =...

Django Context Processor Trouble

So I am just starting out on learning Django, and I'm attempting to complete one of the sample applications from the book. I'm getting stuck now on creating DRY URL's. More specifically, I cannot get my context processor to work. I create my context processor as so: from django.conf import settings #from mysite.settings import ROOT_URL ...

How do I build a custom "list-type" entry to request.POST

Basically I have a model with a ManyToMany field, and then a modelform derived from that model where that field is rendered as a "multiple choice" selectbox. In my template I'm having that field omitted, electing instead to prepare the values for that field in the view, then pass those prepared values into request.POST (actually a copy ...

Django model query with custom select fields

I'm using the row-level permission model known as django-granular-permissions (http://code.google.com/p/django-granular-permissions/). The permission model simply has just two more fields which are content-type and object id. I've used the following query: User.objects.filter(Q(row_permission_set__name='staff') | \ Q(row_permissi...