I want to set the BooleanField inuse to True when I save the ModelForm (I'm using a form outside of the admin area) and I'm unsure how to do it.
Models:
class Location(models.Model):
place = models.CharField(max_length=100)
inuse = models.BooleanField()
class Booking(models.Model):
name = models.CharField(max_length=100, v...
I want to update all rows in queryset by using annotated value.
I have a simple models:
class Relation(models.Model):
rating = models.IntegerField(default=0)
class SignRelation(models.Model):
relation = models.ForeignKey(Relation, related_name='sign_relations')
rating = models.IntegerField(default=0)
And I want to awoid ...
Hi!
I need help on how to save the same (reference to an) object into a ManyToManyField.
For example I have models like this:
class Material(models.Model):
name = models.CharField(max_length=50)
class Compound(models.Model):
materials = models.ManyToManyField(Material)
In this example, the Compound can be made of one or many...
I have a model with a datetime field and I want to show the most viewed entries for the day today.
I thought I might try something like dt_published__date to extract the date from the datetime field but obviously it didn't work.
popular = Entry.objects.filter(type='A', is_public=True).order_by('-dt_published__date', '-views', '-dt_writ...
Hi all,
I'm currently building a web application and I would like my users to have their own URLs to identify them. I could either do this using subdomains or using folders and am wondering what are the advantages and disadvantages of either one.
I really like the folder solution because my URL mapping would be fairly easy. I have read...
I have a simple URLField in my model
link = models.URLField(verify_exists = False, max_length = 225)
I would like to strip the leading and trailing spaces from the field. I don't think I can do this in "clean_fieldname" or in the "clean" method.
Do I need to sub-class the "URLField" and remove the spaces in to_python method? Is ther...
I have a model MyModel that has a field expiration_datetime.
Every time a user retrieves an instance of MyModel I need to first
check if it has expired or not. If it has expired, than I need to
increment some counter, update others, and then extend the
expiration_datetime to some time in the future.
So the view would do something ...
I'm working in a bilingual project (es/en); for this project I've chosen to use django's i18n internationalization system (and I'm starting to regret it...)
Today's problem is the following:
for some models, my database stores information like description and es_description, or english_common_name and spanish_common_name (these are att...
new one to me
commend
I'm running ubuntu 10.04 relatively fresh install on my laptop
manually installed django 1.2.1
when I try to run inside of a virtualenv
python manage.py **any command**
I get the error "bash: /home/alvin/workspace/storm-guard/virtual_damage_restoration/bin/python: cannot execute binary file
"
I have done the fo...
Hi,
In my website, i wanna give users the possibility to upload videos, audio files, and pdfs. For this, i have thought about using formwizard. The first form-page is to ask for the name + the type of file to upload. The second form-page would be determined dynamically based on the answer of the first form.
Is this possible with django's...
Hi
I have a complex django object, which has properties of other class types. This gets like this:
class Order:
contractor - type Person
some other fields....
In my form I'd like to be able to either choose existing Person object from the dropdown or add a new one with a form. I've managed to create forms and appropriate workfl...
I've got PyDev installed in Eclipse. I'm trying to play with Django. I'm got a remote MySQL database set up. I would really like to not install MySQL on my MacBook.
Trying to set up the MySQL plugin for python, I get
(djangotest)jeebus:MySQL-python-1.2.3 blah$ python setup.py clean
sh: mysql_config: command not found
Traceback (most r...
Is there an out of the box way to format in python (or within django templates), a date with full month name in accordance to polish language rules?
I want to get:
6 września 2010
and not:
>>> datetime.today().date().strftime("%d %B %Y")
'06 wrzesień 2010'
...
Similar questions have been asked before on this site, but I had a doubt as to how my site anchor tags will be replaced when I try to host my website under a suburl.
E.g.
My domain is www.example.com
and my suburl which maps to the Django installation is www.example.com/2010/registration
Now since the anchor tags in my templates (for th...
Hi all,
I'm trying to make django work on snow leopard. So far I've installed mysql 64 bit installed python 2.7 64 bit and installed django 1.2.1. Now I'm trying to install mysql-python-1.2.3; at the beginning I had problems because I hadn't installed the setup tool, having done that when try to install it by executing these command
pyt...
I run my local development server on port 8000 because my ISP blocks port 80. The problem is when using:
return HttpResponseRedirect(reverse('foobar'))
Django (for some reason) truncates the port from the URL - but it has no problem resolving it in the context of template tags e.g.: {% url foobar %}.
Since I'm attempting to reduce th...
I can't seem to figure out a good way to do this,
I have a bunch of form input fields and rather than having to do like below where I have to type out each fieldname = "" and such, is there a way to code this so it would automatically save each field from within the form?
b = Modelname(fieldname=request.POST['fieldname'])
b.save()
I ...
I'm trying to do a Django database save from a form where I don't have to manually specify the fieldnames (as I do in the 2nd code block), the way I am trying to do this is as below (1st code block) as I got the tip from another S.O. post. However, when I try this I get the error "dictionary update sequence element #0 has length 4; 2 is ...
In a piston handler, I need to return a django.db.models.query.QuerySet as a proper JSON message (reflective of the underly model and query), while also adding an HttpResponse header of my own. So far, I can do one or the other, but not both (and get a proper looking JSON response).
The below generates a proper JSON formatted response, ...
Hi All,
I am pretty new to Django.
I want the name of my models to be displayed in Chinese, so i used verbose_name in my meta class of my model, codes below:
#this models.py file is encoded in unicode
class TS_zone(models.Model):
index = models.IntegerField()
zone_name = models.CharField(max_length=50);
zone_icon = models...