Here is my simplified model:
class Item(models.Model):
pass
class TrackingPoint(models.Model):
item = models.ForeignKey(Item)
created = models.DateField()
data = models.IntegerField()
class Meta:
unique_together = ('item', 'created')
In many parts of my application I need to retrieve a set of Item's and a...
Hi Folks,
When I try to install ByteFlow on my Windows development machine, I got the following MySQL error, and I don't know what to do, please give me some suggestion. Thank you so much!!!
E:\byteflow-5b6d964917b5>manage.py syncdb
!!! Read about DEBUG in settings_local.py and then remove me !!!
!!! Read about DEBUG in settings_local....
So I have a model that has a field, which originally defaulted to not allow nulls. I want to change it to allow nulls, but syncdb doesn't make the change. Is it as simple as changing it in the database and reflecting it in the models.py file just for the next time its run against a new database?
...
I'm trying to develop an app using Django 1.1 on Webfaction. I'd like to get the IP address of the incoming request, but when I use request.META['REMOTE_ADDR'] it returns 127.0.0.1. There seems to be a number of different ways of getting the address, such as using
HTTP_X_FORWARDED_FOR or plugging in some middleware called SetRemoteAddrF...
I created two new classes which inherit model Entry:
class Entry(models.Model):
LANGUAGE_CHOICES = settings.LANGUAGES
language = models.CharField(max_length=2, verbose_name=_('Comment language'), choices=LANGUAGE_CHOICES)
user = models.ForeignKey(User)
country = models.ForeignKey(Country, null=True, blank=True)
cre...
I have the following django test case that is giving me errors:
class MyTesting(unittest.TestCase):
def setUp(self):
self.u1 = User.objects.create(username='user1')
self.up1 = UserProfile.objects.create(user=self.u1)
def testA(self):
...
def testB(self):
...
When I run my tests, testA will...
This is my situation: I am constructing an ad-like application in Django and Mysql. I am using a flexible-ad approach where we have:
a table with ad categories (several categories such as home, furniture, cars, etc.)
id_category
name
a table with details for the ad categories (home: area, squared meters. car: seats, color.)
id_det...
Hi, I' m trying to build a Django TemplateLoader, but I can't make it 'see' either the current Context or Request, so I can't really do much with it.
Does anyone know how I can make a Django TemplateLoader do this?
Many Thanks
Joe
...
Hi,
I'm trying to run a function defined in the views file of my django app, from the command line. Is there a way to do this?
I understand view functions are supposed to be called from a request but I need this function to be called from a cron eventually.
Thanks
...
Hi guy's , i have an app that have 2 fields: company_name and logo, i'm displaying the companies like radiobutton in my Form from Model, but i want to show the logo company instead of the company label (company name)
Any idea ?
My forms:
class RecargaForm(ModelForm):
compania = forms.ModelChoiceField(queryset=Compania.objects.all(...
After running syncdb and creating a su, where does that get recorded? Settings.py doesn't seem to change.
...
I'm using Phusion Passenger with a ruby app and I'd also like to set it up to work with an django appengine app I'm working on.
Googling for "passenger_wsgi.py" I was able to get the following very simple non-django app working on passenger:
passenger_wsgi.py:
def application(environ, start_response):
response_headers = [('Content-...
I have run into these problems several times and was never able to find a comfortable solution. Let's say my website has the domain name MyDomain.com. When I run the tests on the test machine (a continuous integration server), I will modify the HOSTS file on this machine so the MyDomain.com is mapped to this local machine instead of the ...
I'm having a devil of a time getting Phusion Passenger to work with django-nonrel for Google's App Engine. I can seem to get it to work for GoogleAppEngineLauncher and for the production server but not Passenger; or for Passenger and GoogleAppEngineLauncher but not the production server; or for Passenger and the production server but no...
In my base.html file, I am using
{% if user.is_authenticated %}
<a href="#">{{user.username}}</a>
{% else %} <a href="/acc/login/">log in</a>
Here, even if the user is logged in, the log in button shows up.
Now when I click on the log in link, it shows the username and also the normal login view, saying user is logged in.
So, what's w...
I've added the following to my settings.py file:
import logging
...
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(levelname)s %(message)s',
filename=os.path.join(rootdir, 'django.log'),
filemode='a+')
And in views.py, I've added:
import logging
log = logging.getLogger(__name__)
...
log.info("testing 123!"...
I need a regular expression to validate string with one or more of these characters:
a-z
A-Z
'
àòèéùì
simple white space
FOR EXAMPLE these string are valide:
D' argon calabrò
maryòn l' Ancol
these string are NOT valide:
hello38239
my_house
work [tab] with me
I tryed this:
re.match(r"^[a-zA-Z 'òàèéìù]+$", string )
It s...
I'm trying to save 100 characters form user in a 'microblog' minimal application.
My code seems to not have any mystakes, but doesn't work.
The mistake is in views.py, I can't save the foreign key to user table.
models.py looks like this:
class NewManager(models.Manager):
def create_post(self, post, username):
new = self.model(po...
hi,
I'm doing a form application (similar to django-contact-form) and would like to be able to insert the rendered form in a Django template of another application.
What's the best way to do that? Should I create a template for the form (with for example only {{ form.as_p)? If so how can I insert it in another template?
Thanks
Jul
...
Given a model structure like this:
class Book(models.Model):
user = models.ForeignKey(User)
class Readingdate(models.Model):
book = models.ForeignKey(Book)
date = models.DateField()
One book may have several Readingdates.
How do I list books having at least one Readingdate within a specific year?
I can do this:
from_d...