django

Django: How do I delete Inlines dynamically?

note: answering my own question below. ...

Aggregates in Django templates

In a Django application, I want to display a multi-level (but fixed-depth) tree of model objects in table form. The HTML would look something like this: <tr><td rowspan="2">group 1</td><td>item 1.1</td></tr> <tr><td>item 1.2</td></tr> <tr><td rowspan="3">group 2</td><td>item 2.1</td></tr> <tr><td>item 2.2</td></tr> <tr><td>item 2.3</td>...

Django autoreload for development on every request?

Can a Django app be reloaded on every request ? This is very useful for development. Ruby on Rails does just this. runserver reloads, but it reloads slow, and still sometime one has to stop and start it again for some changes to show up. (For example changes in admin.) mod_wsgi can autoreload on Linux by touching *.wsgi files. On Wi...

Django signal emitting once, received twice -- Why?

I'm working with Django signals, but they seem to be received twice, even if emitted once. Here's the code I'm working with (it's a simple wrapper to use Uploadify with Django)... # Signal-emitting code... emits whenever a file upload is received # ---------------------------------------------------------------- upload_recieved = djang...

Django Templating: how to access properties of the first item in a list

Pretty simple. I have a Python list that I am passing to a Django template. I can specifically access the first item in this list using {{ thelist|first }} However, I also want to access a property of that item... ideally you'd think it would look like this: {{ thelist|first.propertyName }} But alas, it does not. Is there any temp...

"Too many values to unpack" Exception

I'm working on a project in Django and I've just started trying to extend the User model in order to make user profiles. Unfortunately, I've run into a problem: Every time I try to get the user's profile inside of a template (user.get_template.lastIP, for example), I get the following error: Environment: Request Method: GET Request ...

Case-insensitive comparison of sets in Python

I have two sets (although I can do lists, or whatever): a = frozenset(('Today','I','am','fine')) b = frozenset(('hello','how','are','you','today')) I want to get: frozenset(['Today']) or at least: frozenset(['today']) The second option is doable if I lowercase everything I presume, but I'm looking for a more elegant way. Is it ...

Django startup importing causes reverse to happen

This might be an isolated problem, but figured I'd ask in case someone has thoughts on a graceful approach to address it. Here's the setup: -------- views.py -------- from django.http import HttpResponse import shortcuts def mood_dispatcher(request): mood = magic_function_to_guess_my_mood(request) return HttpResponse('Please go to...

django templatetag?

how to use the templatetag of django app? ...

Python: This should be impossible, shouldn't it?

This is part of my Django application which is saving a user's profile in a special way. class SomeUser: def __init__(self, request): self.logged_in = True self.profile = request.user.get_profile() self.favorites = self.profile.favorites.all().values_list('pk', flat=True) def save(self, resp): p...

django - Showing multiple child forms inside parent

I have been studying the modalforms & inline formsets but am not able to wrap my head around my composite objects, and want to see how things are done in django world - I have this hierarchical model "Author" has many "Books" Each "Book" has 4 Sections -> Section-01, Section-02, Section-03 & Section-04 Each "Section" has number of...

Django override default form error messages

Hi all, How can I overwrite the default form error messages (for example: need them in other language) for the all apps in my project (or at least for 1 app) Thanks! ...

Django instance start under Google App Engine

After thinking quite a while about how to make a fast and scalable web application, I am almost decided to go for a combination of Google App Engine, Python+Django, and app-engine-patch. But I came across a comment in the app-engine-patch FAQ that made me think that perhaps the combination is not quite as mature as I thought: it may take...

django. Can a view receive a list as parameter?

Hi, I want to submit a form (by POST) that will submit N (unknown) user_id's. Can I make a view receive those ids as a list? For example def getids(request,list): for id in list: usr = User.objects.get(pk=id); //do something with it. usr.save() Is for id in request.POST['id']: even possible? I'm lookin...

Template-level model methods in Django to respect both DRY and MTV (MVC)?

As an example, let's say there's a Tshirt model on a shopping site, and it will have "summary" markup with a thumbnail, name and price: <div> <a href="detailspage">Awesome TShirt!</a> <img src="thumbnail.jpg" /> <span class="price">$55.99</span> </div> Since this will be on many different pages, I don't want to have to typ...

when i use the django generic view update_object

when i use the django generic update_object view to edit always Page not found (404) Request Method: POST Request URL: http://127.0.0.1:8000/bookmarks/edit/ my url.py (r'^edit/(?P<object_id>\d+)$', update_object, {'form_class':BookForm, 'post_save_redire...

Django pagination and object list show 404 page

Hi guys, i would like to paginate my object list, im tring to use django-pagination, but is showing a 404 page no found when i try to navigate. ulr.py categoria_info = { 'queryset':Categoria.objects.all(), } urlpatterns = patterns('', url(r'^$', object_list, ...

is there any file upload library/third-part application in django?

is there any library or open-source application with the feature: upload images/files from browser upload images/files from a url (download the content and store it) rich user interface like upload progress bar or file manager etc. and any other help or suggestion? I want do an application let user upload picture from there computer o...

Newbie: Django : Adding calculated results to Queryset before passing to template

Hi All Its day two of my new life with Django, please excuse the simplicity of my question. I have an existing DB table(read-only access) that I have successfully displayed the contents of on a webpage using urls, views, models and all that good stuff. The challenge I have is the table does not contain all the information I need to di...

django model Form. Include fields from related models

Hi. I have a model, called Student, which has some fields, and a OneToOne relationship with user (django.contrib.auth.User). class Student(models.Model): phone = models.CharField(max_length = 25 ) birthdate = models.DateField(null=True) gender = models.CharField(max_length=1,choices = GENDER_CHOICES) city = models.C...