I have a user registration form that has a "password" and "confirm password" field. When I add "min_length" to my password field and then run the submitted data through my custom clean_confirm_password method, it gives a "Key Error / Password" error.
This occurs when the password field is less than 5 characters, whether the confirm_pass...
In one of my views I am importing models from two apps:
from mysite.business.models import Location
from mysite.directory.models import Location
As you can see, both Models have the same name. If I want to create an instance of one of these models, how do I define which one I require?
...
I get the following error:
sqlite3.OperationalError: table gallery_image has no column named filename
Here is my Model:
from django.db import models
class Image(models.Model):
filename= models.Field(max_length=40);
gallery = models.ForeignKey('Gallery')
def __unicode__(self):
return u'%s(%s)' % (self.filename,se...
I have the following models:
class Order_type(models.Model):
description = models.CharField()
class Order(models.Model):
type= models.ForeignKey(Order_type)
order_date = models.DateField(default=datetime.date.today)
status = models.CharField()
processed_time= models.TimeField()
I want a list of the order types tha...
I am making a Django Model decorator which takes a Django model and gives it a few extra methods.
Django creates the database name for this Model using: '%s_%s' % (app_name, class_name). When you decorate the Model the table name is suddenly derived from the app name and class name of the decorator rather than the original class (which ...
For instance, I have a field in a model class called Role, and instead of creating a separate Role model by hand, that I then later have to write code to populate with 5 known values, is there a way to express that the Role field in my Person model can only hold those 5 known values?
...
Just wondering because at the moment I am keeping the ImageFields as part of the BlogPost model. If I want to support the potential for 20 images, I have 20 such fields, when often almost 19 of them will never be used. But if I normalize them into a separate model, it's not as intuitive to add images to a post in the admin page, since yo...
hello, after running "python manage.py syncdb" i gett an error saying "unable to open database file".
here is the important part from my settings.py:
DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'apps.db' # Or path to database file if using sqlite3.
DATABASE_...
Hi,
I have a data model in django called MainData which was created on top of a table called "my_data".
I want to perfom a simple calculation on top of this table via django API. The query is as follow:
select main.id,
sum(main.num - secondary.num) as result
from (select * from my_data
where some_value >...
I am trying to take a modelformset, then process the records that have been changed after the form is submitted. For new records, I need to do certain action like set one form field equal to a hidden field and add some time stamps. For edited records, I do not need to do these actions, just to save the model's edited data. For unchaged r...
Is there a good way within Django models to specify a specific index storage type?
For example, the default storage type for MySQL is BTREE, when for my particular column it may be more efficient to have HASH(hash table) as the storage type.
I can't find a good way without creating a custom field, or modifying django core, that will d...
I have a Django model, which is essentially a list of words. It is very simple and is defined as follows:
class Word(models.Model):
word = models.CharField(max_length=100)
I need the particular word as a string object. (I am replacing all the characters in the word with asterisks for a simple Hangman game.) However, I cannot seem ...
I need to make special request to database through django.
For example:
class Model(models.Model):
name=models.CharField()
date=models.DateTimeField()
other=models.TextField()
How do I ask for row which name containe word 'Hello' (it shoul ignor register of first letter)
end it is must be in diapason of date, for exam...
Hello,
I am using the exif.py library. After calling
tags=exif.process_file(...)
i want to retrieve the time the image was captured. so i continue with
t =tags['Image DateTime'] if tags.has_key('Image DateTime') else time.time()
now i want to store t in django's database. For that t must be in the form 2010-07-20 14:37:12 but app...
I have this Article model for a news site with a boolean field called "sticky". The idea is that when the author writes an article and marks it as sticky it should always stay at the top of the list of articles. I wrote a template tag and here's my render method:
def render(self, context):
context[self.varname] = self.model._default...
Do you know any solution to this:
[Thu Jul 08 19:15:38 2010] [error] [client 79.162.31.162] mod_wsgi (pid=3072): Exception occurred processing WSGI script '/home/www/shop/django.wsgi'., referer: http://shop.domain.com/accounts/checkout/?
[Thu Jul 08 19:15:38 2010] [error] [client 79.162.31.162] Traceback (most recent call last):, refere...
One of my models has a 'status' field which is only ever modified in code. It is an integer from 1 to 6 (although this may change in the future).
However, in the Admin site, I would like to display a label for this data. So, instead of displaying '5', I would like it to say 'Error'. This means I would be able to easily filter the object...
If csv file has rich text in it. Using csv.reader() can the same format stored in the Mysql database using django and retrieved back to html pages?
Thanks..
...
Hey guys,
I am trying to do something very basic here with three models:
class Car(models.Model):
country = models.ForeignKey(Country)
company_name = models.CharField(max_length=50)
continent = models.CharField(max_length=50)
class CountryProfile(models.Model):
country = models.ForeignKey(Country)
minimum_wage = models....
What is wrong with the following code for file uploading.The request.FILES['file'] looks empty
Models:
from django.db import models
from django import forms
class UploadFileForm(forms.Form):
title = forms.CharField(max_length=50)
file = forms.FileField(label="Your file")
Views:
def index(request):
if request.m...