django

Binding Files to Forms in Django

Hello everyone, I'm trying to create a form where users can save their progress. I have successfully managed to upload files when they are saved, but for some reason the following code leaves the file that was uploaded unbound from the form and thus making the user reupload the file: class ImageForm(forms.ModelForm): class Meta: ...

Django, displaying a view in an another view?

I would like to know if I can display a view inside another view with django. This is what I tried to do: def displayRow(request, row_id): row = Event.objects.get(pk=row_id) return render_to_response('row.html', {'row': row}) def listEventsSummary(request): listEventsSummary = Event.objects.all().order_by('-id')[:20] r...

Allow only one concurrent login per user in django app

is it possible to allow only one concurrent login per user in django application? if yes, how do you approach? ...

Display gaps in dates with Python and Django

I'm building an application that requires each user to make a post on a daily basis. I'd like to display the gaps in dates where users haven't made posts. Since it doesn't seem like a good idea to insert empty database rows for empty posts, I'm only inserting a record when the user adds a post. The model contains a field named log_date....

Generic relations in Django

Would like to hear your opinion. At the current stage (1.1) would you use generic relations in django or stick to more traditional modeling - given that it's yet impossible to traverse and filter against such relations easily (compared to ForeignKey, ManyToMany, OneToOne relations)? Here is one example - I keep track in the database whe...

How to convert seconds to hh:mm:ss with the Django's date template tag ?

Hello, Edit : is there a way to easily convert {{ value|date:"Z" }} to one of the +hh:mm or -hh:mm formats (because date:"Z" returns xxxx or -xxxx seconds). Show this for more explanations about the needed format. Thank you and sorry for my ugly english. ;) ...

Adding custom JS to a django admin field

In a django application I have the following model: class Appointment(models.Model): #some other fields #address fields zipcode=models.CharField(max_length=5) address=models.CharField(max_length=120) latitude=models.FloatField() longitude=models.FloatField() When I'm rendering an Appointment, I'm just putting a...

Getting Unique Foreign Keys in Django?

Suppose my model looks like this: class Farm(models.Model): name = ... class Tree(models.Model): farm = models.ForeignKey(Farm) ...and I get a QuerySet of Tree objects. How do I determine what farms are represented in that QuerySet? ...

Django - override default User model method

I've been trying to override the default __unicode__() method for the django.contrib.auth.models User model but I can't get it to work. I tried it like this: from django.db import models from django.contrib.auth.models import User class User(models.Model): def __unicode__(self): return "pie" and from django.db i...

In Pinax, how to invite when ACCOUNT_OPEN_SIGNUP = False?

In Pinax, when ACCOUNT_OPEN_SIGNUP = False how does the admin invite more users to the system? How does one generate invitation codes? How do they work? ...

Django ModelForm Wizard - How to create the database object ?

Hello, I have a Model enought big to be cut in 3 Forms. I wanted to use FormWizzard to do that and I am wondering, how to save the information from the form to the database? Everything is from the same model. Do you have any idea of how to do that ? ...

Customize count list

I have this code I'm using to generate a list of records categorized into year, make, series, body style, and color for vehicles. I'd like to customize this further this way: for the year, I want to have only up to 2004 being individual...the rest will fall under other i.e. 2009, 2008, 2007, 2006, 2005, 2004, Other. for the make, I wa...

Best way to add convenience methods to a Django Auth User model?

I want to add a convenience/model method to the django.contrib.auth.models.User model. What is the best practice for doing this since, last time I checked, extending the User model was considered bad practice. I have a separate custom UserProfile model. Should I be using that for all User-related convenience methods? ...

Django-Use of unicode

Why is a unicode function is required in models.py? i.e, def __unicode__(self) return sumid; ...

python logging in django

Hi, I am using the basic python logger in django and it seems to be workng well. I have the logging setup in my setting.py as; logging.baseConfig(level = logging.NOTSET, format='a format', datemt=' a datefmt', filename='path to log', filemod...

django forms to db table

In Django if I an object of type: django.forms.BooleanField for example how do I know what database type it is going to be saved to e.g. Int, Boolean, Varchar? I know Django automatically handles this as part of the models but I want to do this manually so that is not an option. Is there a built in Django function I can call which will ...

django app with app engine on windows

I'm trying to install app engine with django 1.1 on windows. When launching the app engine I'm getting the following error: http://slexy.org/view/s21oLrbkHh The steps I do are: 1.) Create new app via launcher 2.) Copy my code (Which is empty django project) My main.py code is attached below. I'm falling on line: "import django.db" whi...

Combine several variables of different data types into one string

I'd like to combine 6 variables that are of different types in my view...I thought the concatenation '+' will work but I get an error when I use it. I'd like the end result to be like this: var1 var2 var3 var4 (var5 var6) How do I go about this? ...

how to use django mailer without PINAX

I want to use django-mailer without PINAX. When I run ./manager.py send_mail it prints: Unknown command: 'send_mail' Type 'manage.py help' for usage. How do I fix this? Python 2.5.1 (r251:54863, Sep 22 2007, 01:43:31) [GCC 4.2.1 (SUSE Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. (Interac...

Database query across django ManyToManyField

I'd like to find how to select all objects whose ManyToMany field contains another object. I have the following models (stripped down) class Category(models.Model): pass class Picture(models.Model): categories = models.ManyToManyField(Category) visible = models.BooleanField() I need a function to select all the Pictures i...