django

Remove the "Add" functionality in Django admin

Is there a way to remove the "Add" functionality on the Django admin site? For certain entities, I only want the Django admin to be able to view them or change existing ones, but not add new ones. ...

Django form errorlist render position

When I display a form with errors using {{ f.as_p }} , the errorlist ul always comes first then the label and input field. For example: <ul class="errorlist"> <li>This field is required.</li> </ul> <p> <label for="id_content">Content:</label> <textarea id="id_content" class="required error" name="content" cols="80" rows="10"/> </p> I ...

problem in creating a calendar event using gdata in appengine

I am getting a token upgrade failed error when i try to create a calendar reminder using google's gdata used in an appengine environment. The code fragment is: def InsertSingleEvent(calendar_service, title=None, content=None, where=None, start_time=None, end_time=None): event = gdata.calendar.Calen...

django template forloop.counter question

Hi all, i have many fields in my form i was trying to apply different css to neighbour forms fields like <li class='thiscolor' > <field> </li> <li class='thatcolor' > <field> </li> if there a way like {% for field in form %} **{% if forloop.counter%2 == 0 %}** <li class='thiscolor'> {% else%} <li class='thatcolo...

Optimizing Django: getting model information in bulk..?

In a Django view I'm doing something like this.. lists = Stuff.objects.exclude(model2=None) for alist in lists: if alist.model2.model3.id == target_id: addSomeStuff The slowness comes from going from model (database row) to model in the if statement. This actually takes nearly a second to run whe...

Django content-type : how do I get an object?

If I have a django content_type reference (the id of the model.class and the id of the object), what's the best way to get the actual object itself? Sounds trivial but I can't actually see an example anywhere. ...

Django cross-site reverse URLs

Probably simple question and I'm just missing something, but I'm stuck out of ideas. I have Django project serving several sites with distinct sessions.py and completely different ROOT_URLCONFs. One site handles user registration, authentication and profile settings, other site (on another domain) acts as file manager and so on. Sites a...

Why does Django post_save signal give me pre_save data?

Im trying to connect a "Information" object to many "Customers" (see code below) When one Information object is updated, I want to send email to each Customer that is connected to the Information. However, when I log the sold_to field that the signal recieves I always get what the data is like BEFORE the save. I'm guessing this is bec...

signals or triggers in SQLAlchemy

Hi, does SQLAlchemy have something similar to Django's signal concept? Basically, I'd like to trigger a few functions when I pre-save or post-save some entity objects. Thanks. Edit: I JUST want equivalent of django-signals in SQLAlchemy. ...

Dropping the Unicode markers in Html output

I have a python list which holds a few email ids accepted as unicode strings: [u'[email protected]',u'[email protected]',u'[email protected]'] This is assigned to values['Emails'] and values is passed to render as html. The Html renders as this: Emails: [u'[email protected]',u'[email protected]',u'[email protected]'] I would like it to ...

Can I reference a named URL in an included URLConf using Django's "url" tag?

In my Django project, I used to have a single URLConf, urls.py at the root of the project. This URLConf included some named URLs using Django's url() function. In several templates, I reference these URLs with the url tag, à la {% url named_url %}. This worked fine. The root urls.py became a bit unwieldy, so I split it off into a URLCon...

Error starting Django with Pinax

Upon trying to start a Pinax app, I receive the following error: Error: No module named notification Below are the steps I took svn co http://svn.pinaxproject.com/pinax/trunk/ pinax cd pinax/pinax/projects/basic_project ./manage.py syncdb Any suggestions? ...

Python TypeError unsupported operand type(s) for %: 'file' and 'unicode'

I'm working on a django field validation and I can't figure out why I'm getting a type error for this section: def clean_tid(self): data = self.cleaned_data['tid'] stdout_handel = os.popen("/var/www/nsmweb/jre1.6.0_14/bin/java -jar /var/www/nsmweb/sla.jar -t %s grep -v DAN") % data result = stdout_handel.read() Do I have ...

CSSTidy is driving me crazy!!

Hi, I am on OS X + Python 2.6 + django 1.1. I have tried all possible solution available on the net i.e. http://thingsilearned.com/2009/01/02/installing-csstidy-and-scons-on-os-x-or-linux/ tried with python 2.5, 2.4 apple-python.. I just can't go past this error after installing scons $ /usr/local/bin/scons scons: *** No SConstruc...

How do I associate input to a Form with a Model in Django?

In Django, how do I associate a Form with a Model so that data entered into the form are inserted into the database table associated with the Model? How do I save that user input to that database table? For example: class PhoneNumber(models.Model): FirstName = models.CharField(max_length=30) LastName = models.CharField(max_len...

How to stop WSGI from hanging apache

I have django running through WSGI like this : <VirtualHost *:80> WSGIScriptAlias / /home/ptarjan/django/django.wsgi WSGIDaemonProcess ptarjan processes=2 threads=15 display-name=%{GROUP} WSGIProcessGroup ptarjan Alias /media /home/ptarjan/django/mysite/media/ </VirtualHost> But if in python I do : def handler(request...

Syntax highlighting with Markdown & Pygments in Django

I've been trying to get syntax highlighting working in my simple Django (1.1) test app using Markdown (2.0.1) & Pygments (1.0). The idea is to generate HTML from the users input which is in markdown format and store both in the DB so I don't have to do the markdown to html translation during the fetch. So far I have the markdown proce...

Well-behaving RESTful Client Interactions

I have what seems to be a fairly simple question about implementing a data access client that strictly adheres to REST architectural principles. To start, let's assume I have a well-behaving REST API that I want to consume using a Django application. I'll start by discovering what services are available (edited for follow-up): GET examp...

What is the most straightforward path to move a project from Pinax 0.5.1 to 0.7beta3?

I'm updating a 0.5.1 complete_project to 0.7beta3 + virtualenv + pip + fabric. I have converted my project into multiple stand-alone applications and I have everything being pulled down by pip from a requirements.txt file. I am now moving the code over and so far can get the Welcome page and perform a log-in, but then it breaks, due, i...

Django ManyToMany relation add() error

Hi all, I've got a model that looks like this, class PL(models.Model): locid = models.AutoField(primary_key=True) mentionedby = models.ManyToManyField(PRT) class PRT(models.Model): tid = .. The resulting many to many table in mysql is formed as, +------------------+------------+------+-----+---------+----------------+ |...