django

Access a model's field by another field's value in a template in Django?

Hi, I don't really know how to describe what I'm aiming at (EDIT: I want a dynamic attribute lookup), but I'm trying to do something like this <p>{{dict.{{object.field}}}}</p> in a template. I also tried: {% with object.field as field %} {{dict.field}} {% endwith %} wich didn't work either. Do you know how to tackle this properl...

How to implement objects modification trace

Hi there, With django admin, we have an history of who altered an object and when. I would like to add an "old value", "new value" to this to be able to roll back if needed. Plus I would like every modification made to my objects (also outside of admin) to be recorded as well. The final objective is to be able to trace every modificat...

how to use matplotlib in django?

Using Django 1.0.1, Python 2.6.2 (linux) From some examples from the internet I made the test code below. It works! ... BUT if I reload the page, the pie will draw itself in the same image. Some parts get darker every time I reload the page. When I restart the the development server, it is reset. How do I draw properly with matplotlib...

Pip + WSGI import errors

when i deploy my apps that worked fine using the django test server I usually get errors for every package I installed using pip install -e ....#egg=foo. I usually do this using virtualenv, which placed the files into env/src/foo and places another file into python/site-packages (this is an example of django-css): django-css.egg-link, w...

How to make a "workflow" form

Hi there For my project I need many "workflow" forms. I explain myself: The user selects a value in the first field, validates the form and new fields appear depending on the first field value. Then, depending on the others fields, new fields can appear... How can I implement that in a generic way ? ...

Django: get aggregated value of two multipied columns

Hi, I need to get aggregated value of two columns. So first multiple them together and then get theirs sum(). Code below naturallz does not work, it is just for clarification. Is it somehow possible or should I use raw SQL? SomeModel.objects.filter(**something).aggregate(Sum('one_column' * 'another_col')) ...

Validate image size in django admin

I see a lot of people with Django apps that have image uploads are automatically resizing the images after they are uploaded. That is well and good for some cases, but I don't want to do this. Instead, I simply want to force the user to upload a file that is already the proper size. I want to have an ImageField where I force the user t...

Django password change:Reverse for '<function password_change_done at 0xa3b0f0c>' with arguments '()' and keyword arguments '{}' not found.

When inckuded the following in urls.py (r'^settings/users/change_password/$', 'django.contrib.auth.views.password_change' The following shows up on the screen, Reverse for '' with arguments '()' and keyword arguments '{}' not found. And i am trying to give the access to users to change their passwords. Whats wrong with the above cod...

Django + secure mail

I tried configure smtp mail with certificate on Django and I receive 'time out' error( code 110 ?). I use this settings: EMAIL_HOST='some.smtp.serwer' EMAIL_HOST_PASSWORD='' EMAIL_HOST_USER='' EMAIL_PORT=495 EMAIL_USE_TLS=True outlook configuration guide informs about certificate installation, maybe this issue is causing this error ?...

Best way to ensure that at least one field in a model is specified?

I have a model with four fields that all have null=True defined. I'd like to prevent creation of an entirely null model; I'd rather not use a form validator since I want this to work with the default admin. If I override the save() method to do a check, what do I raise on an error? ...

How can I access an uploaded file in universal-newline mode?

I am working with a file uploaded using Django's forms.FileField. This returns an object of type InMemoryUploadedFile. I need to access this file in universal-newline mode. Any ideas on how to do this without saving and then reopening the file? Thanks ...

Django & customising a legacy database

I'm currently working on a project to implement a Django interface to an existing calendar application. The calendar application has MySQL as the backend DB. In our custom application we would like to modify/extend the data in one of the tables used by the existing calendar application e.g. # Auto-generated by inspectdb - table used by...

Add a custom permission to a User

I'd like to be able to give some existing Users a custom permission which I will require for accessing a view. I think I need to add the new permission to the Postgres table auth_permission, but I suspect there is a higher-level way to do this. Also there is a column in auth_permission for content_type and I don't know what its value s...

how to auto-update a Django page only when required ?

As described in http://stackoverflow.com/questions/1836861/how-to-update-a-django-page-without-a-page-reload, I send periodic XMLHTTPRequests from the browser to the server using JavaScript to get those pieces of the webpage that changes during the course of my application. However, most of the time, nothing changes; the server replies ...

Django HTTPS and HTTP Sessions

Hi, I'm using Django 1.1.1 with the ssl redirect middleware. Sessions data (authentication etc.) created via HTTPS are not available in the HTTP portions of the site. What is the best way to make it available without having to make the entire site HTTPS? ...

Django 1.1 - comments - 'render_comment_form' returns TemplateSyntaxError

Hello, I want to simply render a built-in comment form in a template, using Django's builtin commenting module, but this returns a TemplateSyntaxError Exception. I need help debugging this error, please, because after googling and using the Django API reference, I'm still not getting any farther. Info: This is the template '_post.htm...

Django URLs configuration debugging?

What's the best method to debug Django's url configurations? Sometime it just throw out a Unhandled Exception without any hints if there is an error in urls.py Sometimes it throws out errors like "unbalanced parenthesis" but I still dont know which line in urls.py caused the error. ...

Django for web2py developers

Now that I've gotten relatively familiar with web2py, I'd like to give Django a go. What are the main differences? What would be the most efficient way to get started taking into account web2py knowledge? (It must help to have some python application framework knowledge,no?) EDIT Also, if you've used both, can you offer an opinion ...

RabbitMQ gives a "access refused, login refused for user" error when attempting to follow the celery tutorial

I'm attempting to follow the celery tutorial, but I run into a problem when I run python manage.py celeryd: my RabbitMQ server (installed on a virtual machine on my dev box) won't let my user login. I get the following on my Django management console: [ERROR/MainProcess] AMQP Listener: Connection Error: Socket closed. Trying again in 2...

In Django form, custom SelectField and SelectMultipleField

I am using Django everyday now for three month and it is really great. Fast web application development. I have still one thing that I cannot do exactly how I want to. It is the SelectField and SelectMultiple Field. I want to be able to put some args to an option of a Select. I finally success with the optgroup : class EquipmentField...