Hi,
I've been developing on my laptop.
Now, I've uploaded my development project from Django 1.2/Python 2.7 up to Dreamhost created using the Passenger setup. I am using South for migration.
I modified settings.py to access MySQL. Got Admin working.
Questions:
1) Where is the std out shown when you hit the site? (all my print st...
When using the shell, this confused me (the permissions did not reflect changes):
>>> user = User.objects.get(username='test')
>>> user.get_all_permissions()
set([])
>>> p = Permission.objects.get(codename="add_slide")
>>> user.user_permissions.add(p)
>>> user.save()
>>> user.get_all_permissions()
set([])
>>> user = User.objects.get(use...
I am a PHP guy. In PHP I mainly use Doctrine ORM to deal with database issues. I am considering move to Python + Django recently. I know Python but don't have experience with Django. Can anyone who has good knowledge of both Doctrine and ORM in Django give me a comparison of features of these two ORM implementations?
...
I have a view function which needs to perform an xmlrpc call to my engine which runs on twisted. I have googled around for something like that, but there doesn't seem to be any material on django + xmlrpc CLIENT (there's tons of literature on xmlrpc server + django).
The reason behind this is because I am not really familiar with WSGI a...
I've got a field defined like this:
service_types = CharField(widget=CheckboxSelectMultiple(choices=ServiceTypes), initial=[ServiceTypes.OPEN_TRANS])
I want to "clean" it to return a single integer (the choices are encoded as power-of-2 flags):
def clean_service_types(self):
data = self.cleaned_data['service_types']
return su...
I have a model that inherits from Photologues 'ImageModel'. The user can upload photos and everything works fine, however the problem I am running into is when I am creating a form to edit a photo object. Since the ImageModel.image is a required field, and I can't prepopulate a FileField widget with a file already uploaded, if the user...
Hi,
I am a django newbie and in creating my first project I have come to realize that a lot of my boilerplate code (the lists on the side of my page). I have to recreate them in every view and I am trying to stick with DRY but I find myself rewriting the code every time. Is there a way to inherit from my base views and just modify a fe...
I have a django model and model form that look like this:
-models.py
class Menu_Category(models.Model):
merchant = models.ForeignKey(Merchant, related_name='menu_categories')
name = models.CharField(max_length=64)
test_field = models.CharField(max_length=20)
def __unicode__(self):
return self.name
-forms.py
cla...
my model looks like this:
class MyModel(models.Model):
field1 = models.FloatField(default=0)
field2 = models.FloatField(default=0)
This is how it behaves:
>>> m = MyModel()
>>> m.full_clean()
>>> m = MyModel(field1=8.9)
>>> m.full_clean()
>>> m = MyModel(field1='')
>>> m.full_clean()
ValidationError: {'field1': [u'This valu...
I've decided to use django-easytree to create a forum hierarchy in django. I downloaded the source via Mercurial from bitbucket. And added the following to a new django app:
http://bytebucket.org/fivethreeo/django-easytree/src/7ab11cd55b09/docs/install.rst
I added a couple of fields to the model so now it looks like this:
class Exampl...
I am trying to use the SelectDateWidget in a form, but it is telling me that the field is required. My model says that the DateField can be null and blank, and in the admin site, it doesn't have a problem with me leaving it blank. I am using the version of the widget from http://code.djangoproject.com/ticket/9124
Here is the code in my ...
i am using the s3cmd linux utility to deletes files from our amazon s3 bucket. i have created a function in python which calls the s3cmd command line utility and access and deletes the files amazon s3 bucket.
command= 's3cmd -c .s3cfg del s3://project-bucket/images/testimage.jpg'
os.system(command)
when i run the project through djang...
I need to implement a finite-state-machine in order to keep track of a few of my Django project models. I already have a similar app doing that but it's heavily coupled with the others apps models and not reusable in any way. So I decided to re-factor it.
After a few hours, this is what I came up with:
class StateMachine(models.Model):...
This seems like a no-brainer, and I'm hesitant to admit that I've spent about two hours trying to find the answer, but I can't figure out how to run project-level tests for a django project.
Just to be clear, running tests for the apps in the project is no problem. I understand './manage.py test', but it doesn't find the project-level ...
I've got to know and love the Django Test client. I'd really like to use it to test external sites and URLs outside of the current project.
Is this possible?
If not, is there something similar I could use? (ideally in Python)
I don't need to do anything dramatic, just, say, grab a URL and check the status code, check that it took le...
from django.utils.simplejson import dumps, loads
# -*- coding: utf-8 -*-
def index(request):
return render_to_response('test2/index.html')
def add_lang(request):
logging.debug("Got request")
a = request.POST
logging.debug(a["lang"])
lang=dumps(a["lang"])
l = Language(code=lang)
l.save()
lang=loads(lang)
lo...
Let's say I have a model with a field based on the ImageField class.
class Foo(models.Model):
imagefile = models.ImageField('File', upload_to='foo/%Y/%m%/%d/')
Django adds - after first upload - an input tag of type file to let me change it and a link to the image to view it.
I want this original field specific (HTML) code as is...
I'm trying to update my records using XML...so far the first part of the task is done....what I'm wondering is how to get my images onto the saved object (I'm using imagekit for the image handling BTW). My models look like this:
class Photo(ImageModel):
name = models.CharField(max_length=100)
original_image = models.ImageField(...
In django, I would like to reference the class whose method is being called, where the method itself is implemented in its abstract ancestor.
class AbstractFather(models.Model):
class Meta:
abstract = True
def my_method(self):
# >>> Here <<<
class Child(AbstractFather):
pass
I'm looking to do something lik...