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

2014-11-25 Thread Matthieu Rigal
Hi guys, I am using a metaclass to standardize how I link two classes, on Django 1.6. This is done in order to have a generic way of connecting classes without having to know the name of the fields being linked. Basically, I have in my metaclass '*post_new*' method to get the 'other' model, us

Re: redirect or reload page after pdf file generation.

2014-11-25 Thread bo liu
Hi, jai, Do you resolve this it? I have the same issue right now. Could you share your solution? thanks a lot. Bo On Wednesday, November 4, 2009 8:43:12 AM UTC-8, jai_python wrote: > > I save the response content in pdf file and then page will be > redirected and pdf file will be called on

Re: DecimalField returns 'This value must be a decimal number' when blank

2014-11-25 Thread elcaiaimar
It works! You are great Collin! Thank you very much! El domingo, 16 de noviembre de 2014 18:51:43 UTC+1, elcaiaimar escribió: > > Hello everybody, I've a problem with DecimalField at Forms. I've a long > form in my template and I want to left some fields in blank. I've declared > these fields wi

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

2014-11-25 Thread Collin Anderson
Hi all, I agree that it's perfectly fine to not use the built in auth and admin apps, and people do it all the time. But, I wanted to give a quick proof of concept of using the admin with custom permissions. # models.py from django.contrib.auth.models import AbstractBaseUser from django.db impo

Re: is it worth going for version 1.6 for commertial project

2014-11-25 Thread Collin Anderson
Hi All, If it helps, at work we have upgraded all of our websites to django 1.7, and are only now starting to think about using migrations. It's totally possible to use 1.7 without migrations. It's also worth noting that although Django supports 1.6 for another 4-5 months, that's only for secu

Re: my mysite/templates/admin/base_site.html is ignored (tutorial unclear?)

2014-11-25 Thread Collin Anderson
Hi, Wow. Everything you've shown looks right. Here's something to try: replace base_site.html with a completely empty file. That should cause the admin page to be completely blank. If that works, could you post a snippet of where you're changing the template? Are you changing the and expectin

Re: is it worth going for version 1.6 for commertial project

2014-11-25 Thread George Silva
I'm using the new migrations system with a production system and it's been great. No complaint at all. On Tue, Nov 25, 2014 at 11:24 AM, Collin Anderson wrote: > Hi All, > > If it helps, at work we have upgraded all of our websites to django 1.7, > and are only now starting to think about using

Re: Auto-refresh the webpage in the  browser, after modify and save

2014-11-25 Thread Collin Anderson
Hi, The one I've heard of the most is http://livereload.com/. There are other browser plugins too. You could also check out "workspaces" in chrome for css at least. https://developer.chrome.com/devtools/docs/workspaces Collin On Sunday, November 23, 2014 8:23:56 PM UTC-5, Jose Regalado wrote:

Re: Unable to open URL in new tab from ajax hit

2014-11-25 Thread Collin Anderson
Hi, Are you doing cross-domain ajax, or is this all within one site? Does this work? def generate_birt(request): url = '/birt/frameset?__report=report/test.rptdesign&sample=my+parameter&__format=pdf' return HttpResponseRedirect(url,mimetype='pdf') Collin On Monday, November 24, 2014 8

Re: Meta inheritance across abstract base class

2014-11-25 Thread Collin Anderson
Hi, If you define a new class Meta on C, then it will _replace_ the previous class Meta. You can, however have class Meta inherit other class Meta. class Student(CommonInfo): # ... class Meta(CommonInfo.Meta): db_table = 'student_info' https://docs.djangoproject.com/en/dev/topics

Re: Meta inheritance across abstract base class

2014-11-25 Thread Torsten Bronger
Hallöchen! Collin Anderson writes: > If you define a new class Meta on C, then it will _replace_ the > previous class Meta. [...] I indeed have a Meta class in C but it is derived from the upstream Meta class. The inheritance chain in my Meta's is uninterrupted. Tschö, Torsten. -- Torsten Br

Re: my mysite/templates/admin/base_site.html is ignored (tutorial unclear?)

2014-11-25 Thread donarb
On Tuesday, November 25, 2014 5:33:02 AM UTC-8, Collin Anderson wrote: > > Hi, > > Wow. Everything you've shown looks right. > > Here's something to try: replace base_site.html with a completely empty > file. That should cause the admin page to be completely blank. > > If that works, could you p

Preventing race conditions when submitting forms

2014-11-25 Thread Paul Johnston
Hi, Consider an e-commerce site, where Alice and Bob are both editing the product listings. Alice is improving descriptions, while Bob is updating prices. They start editing the Acme Wonder Widget at the same time. Bob finishes first and saves the product with the new price. Alice takes a bit

Re: Preventing race conditions when submitting forms

2014-11-25 Thread Simon Charette
Hi Paul, You might want to take a look at the third party packages listed under the *concurrency* category . I've used django-concurrency in the past and it worked well for me. Simon Le ma

Foreign Key Deletion Problem

2014-11-25 Thread Jann Haber
Dear Django Users, I have been running into a problem with the app I am developing and I haven't been able to find a good solution. Suppose I have the following model: class MyModel(models.Model): a = models.CharField(max_length=255, null=True, blank=True) b = models.ForeignKey('MyOther

Re: Preventing race conditions when submitting forms

2014-11-25 Thread Tim Chase
On 2014-11-25 07:57, Paul Johnston wrote: > Consider an e-commerce site, where Alice and Bob are both editing > the product listings. Alice is improving descriptions, while Bob is > updating prices. They start editing the Acme Wonder Widget at the > same time. Bob finishes first and saves the produ

Re: is it worth going for version 1.6 for commertial project

2014-11-25 Thread Krishnakant Mane
Well then I would go with 1.7. Thanks for all the advise. Happy hacking. Krishnakant.On 11/25/2014 06:54 PM, Collin Anderson wrote: Hi All, If it helps, at work we have upgraded all of our websites to django 1.7, and are only now starting to think about using migrations. It's totally possible

Re: Upgrading Django (to 1.7)

2014-11-25 Thread Andrew Pinkham
Hi, I have just updated Upgrading Django (to 1.7) Part III: Django 1.7's New Features. The App Registry and System Check Framework sections have been updated to be more accessible. For the article: afrg.co/updj17/a3/ For all of the material: afrg.co/updj17/ Part IV will be available before t

Re: Preventing race conditions when submitting forms

2014-11-25 Thread Paul Johnston
Tim, Simon, Thanks for the responses. Looks like django-concurrency is a good fit, and it works the way Tim suggested (so no need to write your own mixins!) One follow-up question: do you have any ideas for conflict resolution? The django-concurrency resolution is pretty basic, but it would be

Re: Foreign Key Deletion Problem

2014-11-25 Thread Simon Charette
Hi Jann, I think you'll need to write a custom deletion handler for this. The following should work: from django.db import models class SetNull(object): """Deletion handler that behaves like `SET_NULL` but also takes a list of extra fields to NULLify.""" def __init__(self, *fields

Re: Preventing race conditions when submitting forms

2014-11-25 Thread Simon Charette
I can't think of a generic way of solving conflict resolution. I'd say it's highly application specific. Le mardi 25 novembre 2014 15:06:53 UTC-5, Paul Johnston a écrit : > > Tim, Simon, > > Thanks for the responses. Looks like django-concurrency is a good fit, and > it works the way Tim suggest

Re: How to deal with CSRF middleware from a crawler

2014-11-25 Thread Torsten Bronger
Hallöchen! Carl Meyer writes: > [...] > > Unless you've modified the CSRF implementation locally, all it > does is check that the CSRF token provided in a cookie matches the > one provided in the POST data. [...] > > But this means that the CSRF protection is simple to bypass in a > case like you

Re: Preventing race conditions when submitting forms

2014-11-25 Thread Cal Leeming
+1 - conflict resolution is not an easy task, and really depends on your business logic/use case. It's worth mentioning that the approach django-concurrency uses may not be suitable for your use case, and in my opinion implementing this restriction on a per model basis is not the best approach, es

Re: Upgrading Django (to 1.7)

2014-11-25 Thread Andrew Pinkham
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 checklist of upgrade steps, as well as a list of all the links used throughout the series: afrg.co/updj17/cl/ afrg.co

ModelAdmin.has_change_permission gives 403

2014-11-25 Thread Mike Dewhirst
From the docs ... https://docs.djangoproject.com/en/1.6/ref/contrib/admin/#django.contrib.admin.ModelAdmin.has_change_permission ... is working nicely except it just pops up a standard error page 403 Forbidden when it returns False. How can I intercept this in the Admin and treat it like an e

Re: Unit-testing Custom Admin Action, requires request and querysets parameters.

2014-11-25 Thread Azam Alias
Hi Collin, I apologise for the late update. Didnt get any notifications from your reply. I have solved this issue as per your suggestion. Pasting the solution for others' reference. Thanks ! from django.test import TestCase from django.contrib.admin.sites import AdminSite from batch_apps.mod

Re: ModelAdmin.has_change_permission gives 403

2014-11-25 Thread Mike Dewhirst
On 26/11/2014 11:59 AM, Mike Dewhirst wrote: From the docs ... https://docs.djangoproject.com/en/1.6/ref/contrib/admin/#django.contrib.admin.ModelAdmin.has_change_permission ... is working nicely except it just pops up a standard error page 403 Forbidden when it returns False. Actually, I mu

Re: Preventing race conditions when submitting forms

2014-11-25 Thread donarb
On Tuesday, November 25, 2014 7:57:08 AM UTC-8, Paul Johnston wrote: > > Hi, > > Consider an e-commerce site, where Alice and Bob are both editing the > product listings. Alice is improving descriptions, while Bob is updating > prices. They start editing the Acme Wonder Widget at the same time. B

Re: Image input missing from POST request

2014-11-25 Thread Abhishek Batra
Hi Collin, Thanks for taking time out to look at this. It turns out that I somehow I copied the rendered HTML wrong! The real problem was that the form id used in input was incorrect and this was the reason for the file not getting uploaded. Separately, this is not really a trick but a fairly