Posted by José Lopes
In some situations you may want to concatenate two QuerySets.
The solution depends whether the QuerySets have the same model or not, and this post shows both solutions.
The information presented was based on this thread.
Posted by José Lopes.
The Django administration has a couple of widgets that can be used in an user's form.
This is mentioned on the Django's documentation ( Media and Django Admin) but no practical example is given. Searching the web we find that a lot of people have tried to use them without success, specially the AdminDateWidget that provides a nice popup calendar for choosing the date.
This post show how one can use this widget, and explains why there have been so many missing attemps.
The information here presented is also valid for the AdminTimeWidget. Other widgets may be subject of future posts.
The first official Django version is out. All posts concerning Django that may follow this one have as object this Django version.
Posted by José Lopes.
This post shows how to create a model in Django with an attributes composed by other two, assuring its unicity.
Posted by José Lopes.
When you upload images on a Django project it is normal to expect to have them displayed when editing the concerned record in the administration page.
This post shows what to do to display the images in the administration change page.
Posted by José Lopes.
While using the Django administration I've got the following validation error on the models.ImageField, despite the files being images:
Upload a valid image. The file you uploaded was either not an image or a corrupted image
This post shows a way to work around this problem.
Posted by José Lopes.
In Django's administration panel the list_display option doesn't supports ManyToManyField fields, as you may confirm on the documentation. This is due because such field would entail executing a separate SQL statement for each row in the table.
The Django documentation suggests, if you want to have these fields visible, that we create a custom method and have it add to the list_display. Unfortunately there is no pratical example, or at least I haven't found one, so I wrote this post to provide such example.