django

Import csv data into database in Django Admin

I've tried to import a csv file into a database by tweaking the modelform inside the admin doing this: models.py: class Data(models.Model): place = models.ForeignKey(Places) time = models.DateTimeField() data_1 = models.DecimalField(max_digits=3, decimal_places=1) data_2 = models.DecimalField(max_digits=3, decimal_place...

Django model instance specific code

Hi, in one of my Django models I have to add specific code for each model instance. Now, I wonder what would be a good way to implement this. My current attempt results in a big, hard to read if statement. Consider the following model: class Foo(models.Model): name = models.CharField(max_length=255) def do_instance_specific_s...

sending email templates in with django

Hello, I want to send an email with a template like this. {% extends "base.html" %} {% block content %} <h2>Invoice Details</h2> <div id="horizontalnav"> <a href="/index/add_invoice">Add an Invoice</a> <a href="/index/work_orders">Add a Work Order</a> <a href="/index/add_payment">Add Payment</a> </div> <ul STYLE="border: 1px soli...

Why doesn't SESSION_EXPIRE_AT_BROWSER_CLOSE = True log the user out when the browser is closed?

According to Django documentation, "if SESSION_EXPIRE_AT_BROWSER_CLOSE is set to True, Django will use browser-length cookies -- cookies that expire as soon as the user closes his or her browser. Use this if you want people to have to log in every time they open a browser." And that is what I did by adding the following line to my setti...

timezone Datatype in django

class MyModel(models.Model): timezone = models.CharField() In the above,should timezone be stored in a char field for the below values, from pytz import all_timezones for t in all_timezones: print t Africa/Abidjan Africa/Accra ---- ---- ...

Django administration view: how to remove auto generated permissions?

Hello. Django administration view automatically generates permissions for all modules and tables - admin, auth, contenttypes etc. Is it possible to remove this permissions from 'Available user permissions' so i can see only permissions that i think are relevant? ...

Django - Form Widgets - Select box - Overriding the style attribute?

I have a Django (1.1) form. One of the fields is CharField with a set number of choices, this is correctly rendered as a <select> box. However the html style attribute for the <select> is set as …style="width: 100px"…. I want to conserve screen space, so I want to change this to style="width: auto", or even just remove the style attribut...

Django form QuerySet for ModelChoiceField

I've got a Form which I'm using the following field in. contact_country = forms.ModelChoiceField(queryset=Country.objects.all()) The Country model looks like this class Country(models.Model): iso = models.CharField(max_length=2) name = models.CharField(max_length=80) printable_name = models.CharField(max_length=80) is...

Django textarea widget <p>

In django admin I am using the textarea widget. When I save data, it is saved inside a <p></p> tag. I dont want this - any solutions, I just want to get the data out without being wrapped in a <p>. Any suggestions? ...

Django and Xinha integration

Hey guys, i try to integrate xinha with my django app. I writed own panel admin, and i need to use xinha editor in one textarea. So: xinha widget.py class Xinha(forms.Textarea): class Media: js = ('/media/v/1/xinha/init.js', '/media/v/1/xinha/XinhaCore.js' '/media/v/1/xi...

Socialregistration: how to make a user-info page that works for both facebook and openid

hi, socialregistration works pretty well but the readme file indicates only how to make a website where openid and facebook users can login. Now how do you: retrieve basic inforamtion like email and name with facebook? retrieve basic inforamtion like email and name with openid? implement a user-info page (like when you click on your ...

Why does Django give me different results for the same query?

For a mock web service I wrote a little Django app, that serves as a web API, which my android application queries. When I make requests tp the API, I am also able to hand over an offset and limit to only have the really necessary data transmitted. Anyway, I ran into the problem, that Django gives me different results for the same query ...

A good way to encrypt database fields? - Django

Hi folks, I've been asked to encrypt various db fields within the db. Problem is that these fields need be decrypted after being read. I'm using Django and SQL Server 2005. Any good ideas? ...

How do you display image objects in a Django template using a custom template tag? (coding included)

I have the following code that fails to display object images. But displays normal images fine. My Model class News(models.Model): title----------- image = models.ImageField(upload_to='images') body------------ Template tag coding from django import template register = template.Library() from ----.models import --- def funct(num): ...

Django convert Model to sql code

Hi, My plan is to be able to dynamically generated sql tables. Since I know django can create sql tables via Models, they must have a function for this. The problem is I can not find this function in the django folder, or maybe I simply don't recognize it. thnx ...

moving django project to google app engine

I am trying to move a django project to google appengine. So I followed http://code.google.com/appengine/articles/django.html . But django.dispatch.dispatcher.connect( log_exception, django.core.signals.got_request_exception) django.dispatch.dispatcher.disconnect( django.db._rollback_on_exception, django.core.signals.got_r...

Django: prevent logging permission errors from shell

From the Django shell (manage.py shell), when attempting to import a python module that uses logging I run into permission problems: the log files are owned by the web app user IOError: [Errno 13] Permission denied: '/path/to/my.log' Is there a way to disable / mock / otherwise work around this issue so I can use the module from the s...

How Do Search Engines See A Localized Django Site?

I have a Django site that uses the localization middleware in combination with gettext and the trans/blocktrans template tags to show visitors different pages depending on the preferred language in their user agent string (which seems to be the standard way of doing things in Django). This works great for supported languages (currently ...

Form uploading files to different server without following

How can I send a file in django to a different server without user being redirected to the server ? So all goes to rewriting this simple php function in django : $filename = 'C:/tmp/myphoto.jpg'; $handler = 'http://www.example.com/upload.php'; $field = 'image'; $res = send_file($filename, $handler, $field); if ($res) { echo 'do...

Serving static files with apache and mod_wsgi without changing apache's configuration?

I have a Django application, and I'm using a shared server hosting, so I cannot change apache's config files. The only thing that I can change is the .htaccess file in my application. I also have a standard django.wsgi python file, as an entry point. In dev environment, I'm using Django to serve the static files, but it is discouraged i...