Aw: Re: How to make database queries that “filters” results according to tuples of values?

2014-11-26 Thread lnzy35en
Hi Vijay,   thank you very much. I have not known, that |= also could be used on Q(). Thought Q is only there for making "or" "not" and so stuff of calls! Great!   Best Regards, Mike   Gesendet: Mittwoch, 26. November 2014 um 20:30 Uhr Von: "Vijay Khemlani" An: django-users@googlegroups.c

Does Django offers a way to generate data grid from database table like web2py

2014-11-26 Thread Sarbjit singh
Hi, I have been using web2py for sometime. I am exploring Django now, in web2py there is a way to generate data grids (using SQLFORM.grid) which generates very net grid based on the data model with support to add new field/edit record/delete record/view record etc. Does Django (or any other pa

Re: Preventing race conditions when submitting forms

2014-11-26 Thread Cal Leeming
Sadly I have to say "good luck with that" if you're using Django, as the forms library does not support partial form data out of the box, and it's architectural design makes this difficult to achieve. This is a particularly annoying restriction of Django, especially when building REST APIs. I'm pre

Re: metaclass on model class calling db.models.options method vs django 1.7

2014-11-26 Thread Collin Anderson
Hi, You could try using [f.name for f in _meta.fields] instead of _meta.get_all_field_names(). It won't include ManyToMany, but it's more likely to be available at this point. Collin On Wednesday, November 26, 2014 11:45:22 AM UTC-5, Matthieu Rigal wrote: > > Hi Collin, > > Thanks for the hin

Re: Stopping request when exception occurs (admin interface)

2014-11-26 Thread Collin Anderson
Hi, Peaking at the code... https://github.com/django/django/blob/cc870b8ef5e3464c6f051e3ef0a25dfc4b597452/django/contrib/admin/options.py#L1430 It looks like it would also log a successful change in the history. Is it possible to detect the change during the validation? Looks like you could o

Re: Preventing race conditions when submitting forms

2014-11-26 Thread Collin Anderson
Hi, On websites where there's a lot of editing happening, I've been trying to minimize the number of fields available on a page for editing. Ideally only the data that changed in the UI even get sent to the server. That way there's less chance of a conflict happening in the first place. Collin

Generated migration blocks my application

2014-11-26 Thread Oliver Meinusch
Hello everybody, I am very big fan of Django. I found Django and Python after several years of php development and working with Python and Django feels like loosing all chains you have never known about ;) In my free time I am developing a web application and cms for my local theatre group. Bec

Re: Upgrading Django (to 1.7)

2014-11-26 Thread Fred Stluka
Andrew, Part 4 looks great! Thanks for the shoutout as a reviewer of Part 4. Like with Part 3, it would be better to link it to my one-man company's corporate site than to just my links page. Use: http://bristle.com I'm re-posting my privately emailed comments on the latest version here so pe

Re: Upgrading Django (to 1.7)

2014-11-26 Thread Fred Stluka
Andrew, Thanks for the shoutout as a reviewer. Would be better to link it to my one-many company's corporate site than to just my links page. Use: http://bristle.com I'm re-posting my privately emailed comments on the latest version here so people can find them as part of this thread. Looks

Re: How to make database queries that “filters” results according to tuples of values?

2014-11-26 Thread Vijay Khemlani
I think you could construct a Q object like this: from django.db.models import Q query = Q() for preference in user.preferences.all(): query |= Q(dish=preference.dish) & Q(ingredient=preference.ingredient) Meal.objects.filter(query) That returns the meals where their (ingredient, dish) comb

Re: Image input missing from POST request

2014-11-26 Thread Abhishek Batra
Hey Fred, I won't rely on w3schools for much. I recommend you check out the description of the form attribute through Mozilla's documentation . It clearly says > An input can only be associated with one form. I haven'

Re: Image input missing from POST request

2014-11-26 Thread Fred Stluka
Abhishek, Good tip about the syntax! I didn't realize you could do that to avoid having to nest the fields inside the . I just looked it up at: - http://www.w3schools.com/tags/att_input_form.asp where it says 2 interesting things: - Not supported in IE - Can specify multiple forms that the sa

How to make database queries that “filters” results according to tuples of values?

2014-11-26 Thread lnzy35en
Hi, let’s assume I have the following model:   class Ingredient(models.Model):     ingredient= models.CharField(max_length=255) class Dish(models.Model):     BREAKFAST = 'bf'     LUNCH = 'l'     DINNER = 'D'     DISH_CHOICES = (     (BREAKFAST, 'Breakfast'),     (LUNCH, 'Lunch')

Problem implementing django-sslserver

2014-11-26 Thread pythonista
The application was working successfully on the Linux server. I am trying to implement the ssl functionality and getting the stack trace below after following the instructions Any suggestions as to what is going on and how to fix this. We are running the dev server with a separate Apache ser

Re: metaclass on model class calling db.models.options method vs django 1.7

2014-11-26 Thread Matthieu Rigal
Hi Collin, Thanks for the hint on get_field(), I had read it, but now I will make sure to update it soon :-) Here is the code of one metaclass: @classmethod def post_new(cls, model, attrs): set_item_field_names = model._meta.get_all_field_names() if not 'item' in set_item_field_names:

Stopping request when exception occurs (admin interface)

2014-11-26 Thread ian . k
Hi there, Hopefully an easy question. I've overridden save_model() in my admin page, and I'm wrapping my obj.save() call in a try/catch so that I can catch a RecordModifiedError. def save_model(self, request, obj, form, change): from concurrency.exceptions import Reco

Re: Foreign Key Deletion Problem

2014-11-26 Thread Jann Haber
Hi Simon, thank you very much for your help. I wasn't aware of the possibility of callable class instances. This solved my problem entirely. Regards, Jann On Tuesday, November 25, 2014 10:07:57 PM UTC+1, Simon Charette wrote: > > Hi Jann, > > I think you'll need to write a custom deletion hand

Re: Meta inheritance across abstract base class

2014-11-26 Thread Collin Anderson
Hi, Ohh. Yup. I didn't read that carefully enough. That behavior doesn't seem expected to me. Expecially considering this sentence: "if the child does not specify an ordering attribute or a get_latest_by attribute, it will inherit these from its parent." Collin On Tuesday, November 25, 2014 9

Re: metaclass on model class calling db.models.options method vs django 1.7

2014-11-26 Thread Collin Anderson
Hi, I feel like there's almost always a way to avoid metaclasses. Have you tried adding your relations in the app.ready() signal? For more context, could you post some of your metaclass code and maybe part of a "AppRegsitryNotReady" traceback or two? Also, get_field_by_name(name)[0] will be de

Re: redirect or reload page after pdf file generation.

2014-11-26 Thread Collin Anderson
Hi Bo, One thing I've done is had the form redirect to a page saying "generating pdf", and then that page has a Collin On Tuesday, November 25, 2014 3:28:31 AM UTC-5, bo liu wrote: > > Hi, jai, > Do you resolve this it? I have the same issue right now. Could you > share your solution? t

Re: defining an app stub using AppConfig?

2014-11-26 Thread Collin Anderson
Hi Eric, I'm not sure, but is this what you want? models = apps.get_app_config(setting.NEWSLETTER_APP).models_module Collin On Tuesday, November 25, 2014 1:50:40 AM UTC-5, Eric Abrahamsen wrote: > > I'm messing around with testing many Github forks of the emencia > newsletter app, looking for

Re: ModelAdmin.has_change_permission gives 403

2014-11-26 Thread Mike Dewhirst
Simon Thank you. Yes I had thought that if/else was a last resort possibility. However, one of the nice features I wanted to retain is "Save as" to let a user copy the records. By the way there are many 1:1 and 1:n records connected to substance. I haven't seen flatten_fieldsets before so I'll

Re: ModelAdmin.has_change_permission gives 403

2014-11-26 Thread Simon Charette
In order to make a model admin read only I suggest you make sure ` get_readonly_fields() ` return all of them. from django.contrib.admin.utils import flatten_fieldsets def get_readonl

Re: Is it wrong to disable a lot of the core django features?

2014-11-26 Thread Gabriel - Iulian Dumbrava
Hi John, I don't know if this would work for you as you indeed have an extra level. I'll do it this way Authorities are the permissions from Django, for example you may have custom permissions (authorities in your case): "can_add_employee", "can_edit_employee", "can_view_employee" Roles would b

Re: Preventing race conditions when submitting forms

2014-11-26 Thread Paul Johnston
Hi, Thanks for the warning on django-concurrency. While it seems to have the right features for me, I hadn't looked at its internals. I was thinking about the UI for conflicts and I wonder if I should treat these as form validation errors. If we have the original data (D), the other change set

Re: Upgrading Django (to 1.7)

2014-11-26 Thread Timothy W. Cook
Excellent resource. Thanks Andrew. On Tue, Nov 25, 2014 at 10:16 PM, Andrew Pinkham wrote: > Hi, > Upgrading Django (to 1.7) Part IV: Upgrade Strategies is now available! > > For the article: > afrg.co/updj17/a4/ > > For all of the material: > afrg.co/updj17/ > > I've also provided a checkli