Django has a DATE_FORMAT and a DATE_TIME_FORMAT options that allow us to choose which format to use when viewing dates, but doesn't apparently let me change the input format for the date when editing or adding in the Django Admin.
The default for the admin is: YYYY-MM-DD
But would be awesome to use: DD-MM-YYYY
Is this integrated in an...
I want to write a unit test for a Django manage.py command that does a backend operation on a database table. How would I invoke the management command directly from code?
I don't want to execute the command on the Operating System's shell from tests.py because I can't use the test environment set up using manage.py test (test databa...
Django creates a search box on the list display page when the field "search_fields" is included in a ModelAdmin.
Some of my inline models refer to the items on the list page. If the search box terms match fields in these inline models, I'd like the results to include the referents in the list.
Example: Database has a table of names and...
I want to trigger a special action in the save() method of a Django model object when I'm saving a new record (not updating an existing record.)
Is the check for (self.id != None) necessary and sufficient to guarantee the self record is new and not being updated? Any special cases this might overlook?
...
I know how to set initial values to a form from the view. But how do I go about letting a generic view set initial values to a form? I can write a wrapper view for the generic view, but I still have no access to the form object instantiation.
The specific goal I'm trying to achieve is to have a user create a new object, using the create...
we have a django app on nginx where users upload media files. the media are huge such as 30min tv and radio programs resulting 100-300mb, and our shared hosting limits the upload to 30mb.
how to embed a smart uploader which will put chunks of 20-30mb instead of trying to upload the large file? we would like not to destroy our highly edi...
Is it possible to make a zip archive and offer it to download, but still not save a file to the hard drive?
...
I have made a inline named as Fooinline. This inline was working fine in Django 1.02 but as soon as I upgraded to Django 1.1 it started giving an error:
**TypeError at /admin/casd/aaas/4028cb901dd9720a011deadd85e8007f/
__init__() got an unexpected keyword argument 'request'**
My Fooinline code is:
class FooInline(InlineModelAdmin):
...
Django tends to fill up horizontal space when adding or editing entries on the admin, but, in some cases, is a real waste of space, when, i.e., editing a date field, 8 characters wide, or a CharField, also 6 or 8 chars wide, and then the edit box goes up to 15 or 20 chars.
How can I tell the admin how wide a textbox should be, or the he...
This doesn't work:
>>> pa = Person.objects.all()
>>> pa[2].nickname
u'arst'
>>> pa[2].nickname = 'something else'
>>> pa[2].save()
>>> pa[2].nickname
u'arst'
But it works if you take
p = Person.objects.get(pk=2)
and change the nick.
Why so.
...
Hello!
I am having a rather weird problem in a sense that I can't understand what it might be. My site uses django-registration and all works fine, but if I restart django dev. server in the middle of the session (i.e. been logged in) I immediately get error:
Caught an exception while rendering: Reverse for 'django.contrib.auth.decorat...
I am getting an error when I try to use syncdb:
python manage.py syncdb
Error message:
File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 83, in __init__
raise EnvironmentError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)
EnvironmentError: ...
Hi,
I have a Django model created for Google's App Engine,
Model A():
propA = ReferenceProperty(B)
Model B():
propB = ReferenceProperty(C)
Model C():
propC = ReferenceProperty(B)
I have written custom Django serializer which will fetch the data for the ReferenceProperty(s) and serialize that along the initial model.
The prob...
I keep getting this error/warning, which is annoying, and wanted to see if I can fix it, but I'm not sure where to start (I'm a newbie):
/home/simi/workspace/hssn_svn/hssn/../hssn/log/loggers.py:28: UserWarning: ERROR: Could not configure logging
warnings.warn('ERROR: Could not configure logging', UserWarning)
I'm getting this when ...
Hello!
Is there a way to somehow trace importing of the views ? I want to find which one is broken and doesn't import in some situations (which leads to the fact that all url resolving schema in django stops working).
...
I've been working with a Django app for a while, and the Django admin interface works great, except that the "View on site" link doesn't work. Whenever I try to use it, I get an OperationalError with the message: no such table: django_site. I've done some research into this problem, and it seems that I have to set up the Django sites fra...
Hi. The site makes use of 2 objects - articles and blogs. Every time an article or blog is viewed, a related counter should increase by one.
The idea is to have a "top ten" application that measures the "popularity" of the articles and entries.
Because I'm using more than one object, I would like the Tracker model to use a genericFo...
is there a way to do a query and exclude a list of things instead of calling exclude multiple times?
...
Is there any simple mechanism for overriding Django settings for a unit test? I have a manager on one of my models that returns a specific number of the latest objects. The number of objects it returns is defined by a NUM_LATEST setting.
This has the potential to make my tests fail if someone were to change the setting. How can I ove...
I'm using Django forms in my website and would like to control the order of the fields.
Here's how I define my forms:
class edit_form(forms.Form):
summary = forms.CharField()
description = forms.CharField(widget=forms.TextArea)
class create_form(edit_form):
name = forms.CharField()
The name is immutable and should only ...