Re: Aggregation and following relationships backwards multiple levels

2017-02-01 Thread Patrick Joy
dget__budge__in= > self.budget_set.all()).aggregate(Sum('total'))['total__sum'] > > try like this..! > > On Wed, Feb 1, 2017 at 7:14 PM, Patrick Joy > wrote: > >> Hi all, >> >> Would appreciate some advice on this, I'm having trouble working out

Aggregation and following relationships backwards multiple levels

2017-02-01 Thread Patrick Joy
Hi all, Would appreciate some advice on this, I'm having trouble working out the best way to aggregate across multiple foreign key relationships. I have come up with the solution below however I'm not sure if this is the correct way to handle this situation. Any advice would be appreciated. Th

Help required using pre_fetched data in aggregate()

2013-08-24 Thread Patrick Joy
Hi all, Would appreciate some help on how to optimise the following piece of code. I have two models, "invoice" and "invoice item". The invoice total is calculated in invoice_total() by aggregation the sub_total and tax_total from all invoice_items (see code below). The problem I have is that

youtube video embedding

2013-01-15 Thread joy
hello, my problem is bout embedding youtube's video in my application. I found some workarounds, the first, works for a normal iframe, and uses the url.py to redirect the src tag to youtube: http://sta

Newbie: problems searching a model's field from a template

2013-01-14 Thread joy
it's the first time i try using the model property so probably i'm doing something wrong. This is the model file: from django.db import models # Create your models here. class Pop(models.Model): name = models.CharField(max_length=10) content = models.TextField(blank=True, null=True)

Re: Can't set static file directory.

2013-01-08 Thread joy
I have the same problem, the tutorial speaks about a list of things to do: - Push your code up to the deployment server. - On the server, run collectstaticto copy all the static files into STATI

how to include html in your text area

2012-12-06 Thread joy
May i use html inside a text area? (i need some link in my text but the TextField of my object Text gives me back the html without formatting it) Is there any workaround? Joy -- You received this message because you are subscribed to the Google Groups "Django users" group. To

How to introduce a text area as a field of a database entry

2012-12-06 Thread joy
? def __unicode__(self): return self.pag thanks Joy -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/z16sMIJfAT0J.

Re: datetime deosn't work, first part of the manual

2012-12-02 Thread joy
Sorry, i got it... Il giorno domenica 2 dicembre 2012 17:55:42 UTC+1, joy ha scritto: > > return self.pub_date >= timezone.now() - datetime.timedelta(days=1) > NameError: global name 'datetime' is not defined > > But the timezone module is imported in modules.py >

datetime deosn't work, first part of the manual

2012-12-02 Thread joy
return self.pub_date >= timezone.now() - datetime.timedelta(days=1) NameError: global name 'datetime' is not defined But the timezone module is imported in modules.py should i define it somewhere else? Joy -- You received this message because you are subscribed to the Google Gr

Can't undestrand Url pagination and template

2012-12-02 Thread joy
al on templates. I'm trying with the website of django hoping on something better. Let me know Joy -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-us

Re: Custom form field validation and required=False

2010-07-17 Thread Paddy Joy
the methods > raise ValidationError, the validation stops and that error is raised. > This method returns the clean data, which is then inserted into the > cleaned_data dictionary of the form. > """http://docs.djangoproject.com/en/dev/ref/forms/validation/ > > hth, >

Custom form field validation and required=False

2010-07-16 Thread Paddy Joy
I'm trying to create a custom form field that will validate against auth.user. The field should throw a validation error if the user does not exist, otherwise the field should validate. So far I have: class ExistingUserField(forms.CharField): def clean(self, value): # Check if the use

Re: Need help

2010-06-01 Thread JIffin Joy Akkarappatty
The following may help you http://www.3captus.com/download/django_calendar http://code.google.com/p/django-gencal/ http://www.ohloh.net/p/django-calendar http://www.simonharrison.info/django-calendar/ Thanks & Regards, Jiffin Joy Akkarappatty. On Wed, Jun 2, 2010 at 4:56 AM, Di

Re: I need django open-source project to newspaper

2010-04-19 Thread JIffin Joy Akkarappatty
May help this http://code.google.com/p/django-pennypress/ http://code.google.com/p/pynews2/ Thanks & Regards, Jiffin Joy Akkarappatty. On Mon, Apr 19, 2010 at 1:11 AM, Hussain Deikna wrote: > Hi for all, please I need an open source newspaper web side . > thank you bye >

Re: html to a database.

2010-02-07 Thread JIffin Joy Akkarappatty
Hi, I'm not sure but pls check it out the following links 1. http://www.mercurytide.co.uk/news/article/django-full-text-search/ 2. http://pkarl.com/articles/guide-django-full-text-search-sphinx-and-django-sp/ Thanks & Regards, Jiffin Joy Akkarappatty. On Mon, Feb 8, 2010 a

Re: Django FormWizard Dynamically Alter form_list

2010-02-02 Thread Paddy Joy
I had a similar issue but never got to the bottom of it so I am interested to know if you figured this out? In this bug (a similar issue to yours) http://code.djangoproject.com/ticket/8808 Jacob mentions that a workaround is to "instantiate the wizard in a view function". I tried to figure out ho

Re: how to do a form with elements drawn from database (not hard-wired in forms.py)?

2010-01-19 Thread Paddy Joy
Also take a look at the code for django-survey at http://code.google.com/p/django-survey/ This helped me a lot when I needed to do something similar last year. Paddy On Jan 19, 8:42 am, dk wrote: > I have an application in which I'd like to present a form whose > elements are stored in a datab

Re: csrf error on login and admin

2009-12-15 Thread Paddy Joy
Try 'django.middleware.csrf.CsrfMiddleware' instead of 'django.contrib.csrf.middleware.CsrfMiddleware' Paddy On Dec 15, 4:28 pm, Kenneth Gonsalves wrote: > On Tuesday 15 Dec 2009 9:07:38 am Kenneth Gonsalves wrote: > > > > I tried another browser - same problem of erratic behaviour, at times > >

Problem with adding multiple aggregates to clause with join

2009-10-06 Thread Paddy Joy
Can anyone help out with the following aggregation clause? I have an invoice and invoice_item models as shown. class Invoice(models.Model): customer = models.ForeignKey(Customer) payments_received = models.FloatField(default=0) class Invoice_Item(models.Model): invoice = models.F

Re: Help customizing the admin functionality

2009-09-21 Thread JIffin Joy Akkarappatty
I hope this link will help u in the case of UI : http://flowplayer.org/tools/demos/index.html especially the point 7. Thanks & Regards, Jiffin Joy Akkarappatty. On Mon, Sep 21, 2009 at 5:28 PM, gustavo wrote: > > Hello friends! > > I am changing from php to python. &

Different form in Admin for add vs edit

2009-08-21 Thread Paddy Joy
Is it possible to use a different form in the Admin depending on whether a model instance is being created or edited? For example I have a form that is used to add a member (django user + profile), the form has a password and confirm password field. This is fine for creating the member but when t

Re: django-registration using a different registration form

2009-06-11 Thread Paddy Joy
27;^%saccounts/' % settings.BASE_URL, include ('registration.urls')), Paddy On Jun 11, 10:43 am, creecode wrote: > Hello Paddy, > > You can do the later. Put your url above the include for registration > and you should be good to go. > > On Jun 10, 3:26 pm, Paddy Joy wr

django-registration using a different registration form

2009-06-10 Thread Paddy Joy
I have been reading the django-registration docs and have learned I can change the registration form by using the 'form_class' keyword argument. http://bitbucket.org/ubernostrum/django-registration/src/b360801eae96/docs/views.txt To make this work do I need to rewrite the included urls with my o

Accessing related object data in template

2009-05-02 Thread Paddy Joy
I have a model "Car" with a related model "Car_Attribute" where I store instance specific details. class Car(models.Model): name = models.CharField(max_length=50) class Car_Attribute(models.Model): car = models.ForeignKey(Car) key = models.CharField(max_length=50) data = models.

Re: Custom validation in view?

2009-04-04 Thread Paddy Joy
Thanks Alex that's exactly what I was looking for! Paddy On Apr 5, 10:40 am, Alex Gaynor wrote: > On Sat, Apr 4, 2009 at 8:37 PM, Paddy Joy wrote: > > > I need to validate some data from a form however I need access to the > > request object as the data validation will

Custom validation in view?

2009-04-04 Thread Paddy Joy
I need to validate some data from a form however I need access to the request object as the data validation will be different depending on the logged on user. What is the preferred method for this type of validation? Can i validate thee data in the view and manually set the form field errors? Pa

inlineformset_factory ordering

2009-04-01 Thread Paddy Joy
Is it possible to order the forms in an inlineformset_factory? I have tried ordering the forms in the template using the following but I still see a different order everytime I refresh the page. {% for form in formset.initial_forms|dictsort:"id" %} I'm on SVN 10361. Anyone any ideas? Paddy -

redirect back after save

2009-03-28 Thread Paddy Joy
I have a form that can be called from multiple places. What's the best way to redirect back to the original page after the form has been saved. Do I need to extract the HTTP referrer or is there a better way? Paddy --~--~-~--~~~---~--~~ You received this message b

Re: admin list display icons for callable?

2009-01-27 Thread Paddy Joy
Thanks guys, it was staring me in the face but I didn't get it until the 4th or 5th re-read! Creating links in the list display with allow_tags is a great feature. Paddy On Jan 27, 5:42 pm, Malcolm Tredinnick wrote: > On Mon, 2009-01-26 at 21:51 -0800, Paddy Joy wrote: > > The a

admin list display icons for callable?

2009-01-26 Thread Paddy Joy
The admin interface shows nice green/red icons for BooleanFields. If I have a callable that returns only true or false, is there a way I can make these show in the admin with icons rather than the text 'True'/'False' For example I would like the callable 'photo_ad' to show on the list display wit

Re: Overriding contrib.auth User save()

2008-11-28 Thread Paddy Joy
hope this could help you! > > And finally the other way i usually use is extend a new Client Model > from User, so i have a plenty access to the User Model > and also from the request i get it through request.user.client and i > override the save method for it. > > Regards, > >

Re: Overriding contrib.auth User save()

2008-11-27 Thread Paddy Joy
:01 am, "Alex Koshelev" <[EMAIL PROTECTED]> wrote: > > > Of course you can monkey-patch the User model but the better way is to use > > signals pre_ or post_save > > > On Wed, Nov 26, 2008 at 13:54, Paddy Joy <[EMAIL PROTECTED]> wrote: > > > &g

Overriding contrib.auth User save()

2008-11-26 Thread Paddy Joy
I would like to override the save() method on the contrib.auth User model so that I can run a routine when a user is created/modified. Is this possible or do I need to use a signal? I have tried overriding the User model like this but it never seems to call my code: from django.contrib.auth.mode

Re: Form with 2 models

2008-10-29 Thread Paddy Joy
Masklinn wrote: > On 29 Oct 2008, at 15:06 , Paddy Joy wrote: > > Is there an easy way of doing this or do I need to create a custom > > form that contains the fields of both models and then separate the > > data in my view? > > > > Paddy > > What's

Form with 2 models

2008-10-29 Thread Paddy Joy
I have an Account model: class Account(models.Model): accountname = models.CharField(max_length=50, unique=True) owner = models.ForeignKey(User) admins = models.ManyToManyField(User, related_name='admins', blank=True) accounts = models.ManyToManyField(User, relate

Re: Hidding form field based on logged on user

2008-09-29 Thread Paddy Joy
Thanks for the tip I didn't know you could define the formclass like that. Definately makes it more readable. Paddy On Sep 28, 11:28 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > Steve Holden wrote: > > Paddy Joy wrote: > > >> I have a model with a 'U

Hidding form field based on logged on user

2008-09-28 Thread Paddy Joy
I have a model with a 'User' foreign key. class Domain(models.Model): . owner = models.ForeignKey(User) I have a requirement to only allow superuers to change the 'owner' field. I can do this by creating two model forms and excluding the 'owner' field from one: class DomainForm

Re: User Profiles "user.get_profile()" returns 'matching query does not exist.'

2008-09-20 Thread Paddy Joy
The error message is telling you that the user has no profile (Specifically there is no record in the table schedule.profile related to the user). Your app needs to take care of creating the user profile, even if it going to be empty. What I have done in my case is I force the user to create a pr

Re: add field to form after post

2008-09-06 Thread Paddy Joy
Try it like this: form_data = request.POST.copy() form_data['missing_field'] = some_value submitted_form = SomeForm(form_data) Not sure if this is the best approach but it should work. Paddy On Sep 7, 10:48 am, todbramble <[EMAIL PROTECTED]> wr

Re: Web hosting control panel with django

2008-08-26 Thread Paddy Joy
ng sudo for the www > user to get around it, but dont think thats a very secure solution. > > On Aug 20, 12:16 am, Paddy Joy <[EMAIL PROTECTED]> wrote: > > > I'm also developing a control panel as a personal project for a shared > > hosting setup. > > > The

Modify data before save?

2008-08-24 Thread Paddy Joy
What is the best way to modify form data before it is saved to the database? I have tried the following but can't seem to get it to work, can anyone help? models.py -- class MailBox(models.Model): domain = models.ForeignKey(Domain, core=True) address = models.Ch

Re: Modify data before save?

2008-08-23 Thread Paddy Joy
Thanks should have been more specific. Turns out it was a typo on my part, I should have had: def clean_password(self): instead of def clean_Password(self): Paddy On Aug 24, 2:19 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Sat, Aug 23, 2008 at

Re: fcgi - Problem using daemonize=true

2008-08-21 Thread Paddy Joy
>   -- Scott > > > > On Thu, Aug 21, 2008 at 5:50 AM, Paddy Joy <[EMAIL PROTECTED]> wrote: > > > I'm not sure what's going on here, can anyone help? > > > When I run the following command: > > > python manage.py runfcgi daemonize=false

fcgi - Problem using daemonize=true

2008-08-21 Thread Paddy Joy
I'm not sure what's going on here, can anyone help? When I run the following command: python manage.py runfcgi daemonize=false method=threaded host=127.0.0.1 port=3033 pidfile=django.pid everything works fine. The file django.pid is created and I can access my django app through an apache vhos

Re: Web hosting control panel with django

2008-08-19 Thread Paddy Joy
I'm also developing a control panel as a personal project for a shared hosting setup. The features I'm working on at the moment are: DNS - frontend for myDNS Mail - frontend for Postfix (running mysql backend) With user management and vhost management I have hit a bit of a stumbling block. I'm

Re: formset - Determining if a form is new?

2008-08-19 Thread Paddy Joy
Thanks Justin that's exactly what I was looking for. Paddy On Aug 20, 2:34 pm, "Justin Fagnani" <[EMAIL PROTECTED]> wrote: > Paddy, > > You can use formset.initial_forms and formset.extra_forms instead of > formset.forms > > -Justin > > On Tu

formset - Determining if a form is new?

2008-08-19 Thread Paddy Joy
I would like to determine which forms within a formset are new forms and which forms are existing forms. For example if I create a formset with extra=3, I would like to put the 3 extra forms into a seperate fieldset for readability reasons. I have tried building some logic into the template but

Re: Ideas for adding default records

2007-10-01 Thread Paddy Joy
d loop through it. Is there any standard for doing this sort of thing? Paddy On Oct 1, 6:59 pm, "Jonathan Buchanan" <[EMAIL PROTECTED]> wrote: > On 10/1/07, Paddy Joy <[EMAIL PROTECTED]> wrote: > > > > > > > I have a many to one relationship between

Ideas for adding default records

2007-10-01 Thread Paddy Joy
I have a many to one relationship between domain and DNSRecord. When adding a domain I need to add some default DNSRecords. I do this after saving the domain using the following code. domain = form.save(commit=True) d = DNSRecord(domain=domain, type='NS', data='ns1.mydomain.com', aux=0, ttl=720

Re: Redirect after login problem

2007-09-30 Thread Paddy Joy
Thanks guys, I didn't fully understand the meaning of "redirect_field_name". @login_required() on it's own works as expected. Paddy On Sep 30, 3:19 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 9/29/07, Paddy Joy <[EMAIL PROTECTED]&

Redirect after login problem

2007-09-29 Thread Paddy Joy
I'm having some problems getting the "next" variable to work in the authentication module. After a user is logged in the page is redirected to /accounts/profile rather than being directed to the "next" variable. I'm using the following code, anyone got any ideas what could be wrong? views.py @l

Re: Validation after form.save(commit=False) - newforms

2007-09-27 Thread Paddy Joy
e idea. Obviously the DNSRecordForm will > have to have the domain field in it. > -richard > > On Sep 26, 2007, at 8:30 AM, Paddy Joy wrote: > > > > > Is there a way I can validate form data after doing > > form.save(commit=False)? > > > I am using (commit

Validation after form.save(commit=False) - newforms

2007-09-26 Thread Paddy Joy
Is there a way I can validate form data after doing form.save(commit=False)? I am using (commit=False) because I want to set the model ForeignKey after the data has been posted, for example here is my view: def domain_dnsrecords(request, domain_id): DNSRecordForm = forms.form_for_model