Database operators for custom fields

2014-02-19 Thread Johannes Schneider

hey list,

I have a custom Field implemented for one of my models. How do I 
implement the database operations (e.g. '==', '!=') for the custom field 
which are used to execute database queries?


bg,
Johannes
--
Johannes Schneider
Webentwicklung
johannes.schnei...@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/53049967.8030907%40galileo-press.de.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Database operators for custom fields

2014-02-19 Thread Serdar Dalgic
Hi!

In python, '==' operator is set to '__eq__' and '!=' operator is set
to '__ne__' functions.

See more details in http://jcalderone.livejournal.com/32837.html

And In order to make queries from the ORM, Django uses Managers
https://docs.djangoproject.com/en/dev/topics/db/managers/

So you can write a Manager for the model that has this custom field,
override the __eq__ and __ne__ operations on this custom field and
implement as you like.

Good days!


On Wed, Feb 19, 2014 at 1:45 PM, Johannes Schneider
 wrote:
> hey list,
>
> I have a custom Field implemented for one of my models. How do I implement
> the database operations (e.g. '==', '!=') for the custom field which are
> used to execute database queries?
>
> bg,
> Johannes
> --
> Johannes Schneider
> Webentwicklung
> johannes.schnei...@galileo-press.de
> Tel.: +49.228.42150.xxx
>
> Galileo Press GmbH
> Rheinwerkallee 4 - 53227 Bonn - Germany
> Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
> http://www.galileo-press.de/
>
> Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
> HRB 8363 Amtsgericht Bonn
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/53049967.8030907%40galileo-press.de.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
- Serdar Dalgıç 
FLOSS Developer, Life & Nature Hacker
twitter:
https://twitter.com/serdaroncode
https://twitter.com/serdarintowild

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJH%2Boppn9s%3D2q%3DFQB%3DsBFXObT-sGWNDa%2BLxGNWfB-bi4F31SXA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Newbie Question - Where to store application constants?

2014-02-19 Thread Mark Phillips
Kirby,

You have a good point. However, in this use case I am dealing with
a jewelry store buying gold at their "market" rate. It is not the same as
owning gold and the value changes based on a published (ie available
through an API) rate. The jewelry store market rate for gold changes
slowly, and from store to store So, I found creating a table called
constants in the database allows me to change the value as needed and not
have to touch the app code.

Mark


On Mon, Feb 17, 2014 at 10:20 AM, C. Kirby  wrote:

> I would suggest that your example, the price of gold, isn't a constant. If
> you want to treat it as such then I agree with the above answers. However,
> you could also look around for APIs that publish commodities values and
> actually pull the real values in real (or semi real) time.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/236a1a12-151d-4730-af8c-c5cdc30a0287%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEqej2MR1Q0Dqe%2BFEkzSjgZaxDKnN1RFesHh64G3iyyp8gaSxA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Newbie question about django-cas

2014-02-19 Thread wasingej
Hello.  

I am trying to put together a little test application which allows a user 
to log in to a CAS server and then redirects them back to the site after 
they have logged in.  I have followed the instructions on this page:  
https://bitbucket.org/cpcc/django-cas/overview. 

The URL for my server is: login.oregonstate.edu-dev/login

However, when I try to access http://127.0.0.1:8000/accounts/login, I get 
redirected to:  
http://127.0.0.1:8000/accounts/login/login.oregonstate.edu-dev/login?service=http%3A%2F%2F127.0.0.1%3A8000%2Faccounts%2Flogin%2F%3Fnext%3D%252F

Can anybody point me in the right direction as to what's going on here?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/44bfea1a-0a45-44bd-acaf-63a8f717d53a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Newbie question about django-cas

2014-02-19 Thread Tobias Ramos
try to set your login url to:  http://127.0.0.1:8000/accounts/login while
you testing.

Tobias


On 19 February 2014 15:04, wasingej  wrote:

> Hello.
>
> I am trying to put together a little test application which allows a user
> to log in to a CAS server and then redirects them back to the site after
> they have logged in.  I have followed the instructions on this page:
> https://bitbucket.org/cpcc/django-cas/overview.
>
> The URL for my server is: login.oregonstate.edu-dev/login
>
> However, when I try to access http://127.0.0.1:8000/accounts/login, I get
> redirected to:
>
> http://127.0.0.1:8000/accounts/login/login.oregonstate.edu-dev/login?service=http%3A%2F%2F127.0.0.1%3A8000%2Faccounts%2Flogin%2F%3Fnext%3D%252F
>
> Can anybody point me in the right direction as to what's going on here?
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/44bfea1a-0a45-44bd-acaf-63a8f717d53a%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHwEBHMuuGvhgf6LBqaRnbHpLe%3DgmGxHeXM3cMa-Fo_vKNqtyQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Newbie question about django-cas

2014-02-19 Thread Esau Rodriguez
Hi there,
you have to put the absolute url for CAS_SERVER_URL

try CAS_SERVER_URL=http://login.oregonstate.edu-dev/login (or https)

Regards,
Esau Rodriguez.


On Wed, Feb 19, 2014 at 6:04 PM, wasingej  wrote:
> Hello.
>
> I am trying to put together a little test application which allows a user to
> log in to a CAS server and then redirects them back to the site after they
> have logged in.  I have followed the instructions on this page:
> https://bitbucket.org/cpcc/django-cas/overview.
>
> The URL for my server is: login.oregonstate.edu-dev/login
>
> However, when I try to access http://127.0.0.1:8000/accounts/login, I get
> redirected to:
> http://127.0.0.1:8000/accounts/login/login.oregonstate.edu-dev/login?service=http%3A%2F%2F127.0.0.1%3A8000%2Faccounts%2Flogin%2F%3Fnext%3D%252F
>
> Can anybody point me in the right direction as to what's going on here?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/44bfea1a-0a45-44bd-acaf-63a8f717d53a%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
Esaú Rodríguez
esa...@gmail.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB4Jw77Ke0z5DVCMGR8pzJ91Xzsrjb-xu4KdXGVvwz_gaVAHWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


platform for mainstream enterprise applications

2014-02-19 Thread Marc Model
 

I am a Django newbie.

I expect that Django could be a good platform to build a force.com like 
application platform: a platform where business experts can define business 
data models, authorization rules (which user role can access or edit what 
parts of a model in what state) and workflow rules. 

I wander if there are already initiatives out there to build this type of 
platform, or components of it? 

For instance I found on the internet some discussion around dynamic models 
(classes) exploiting meta-programming facilities of Django. That could be 
the foundation of such platform.

Thanks for any referral.

Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d099d61a-ea08-4710-8ba9-beb6a19102c9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Newbie question about django-cas

2014-02-19 Thread wasingej
The problem is fixed.  Thanks esauro :)

Jared

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d3d1b273-53ed-45db-b5c5-c3d8c6b72f75%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Database operators for custom fields

2014-02-19 Thread Anssi Kääriäinen
If I am not mistaken you are trying to alter how 
.filter(customfield__eq=val) and friends work.

In current Django versions you can't easily customize the SQL generated for 
ORM lookups. In Django 1.7 (currently in alpha) this is possible using 
custom lookups. Custom lookups will allow you to alter the SQL generated 
for different lookups (and also add new lookups if need be). See 
https://docs.djangoproject.com/en/dev/ref/models/custom-lookups/ for all 
the details.

 - Anssi

On Wednesday, February 19, 2014 1:45:43 PM UTC+2, johannes.schneider wrote:
>
> hey list, 
>
> I have a custom Field implemented for one of my models. How do I 
> implement the database operations (e.g. '==', '!=') for the custom field 
> which are used to execute database queries? 
>
> bg, 
> Johannes 
> -- 
> Johannes Schneider 
> Webentwicklung 
> johannes@galileo-press.de  
> Tel.: +49.228.42150.xxx 
>
> Galileo Press GmbH 
> Rheinwerkallee 4 - 53227 Bonn - Germany 
> Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax) 
> http://www.galileo-press.de/ 
>
> Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker 
> HRB 8363 Amtsgericht Bonn 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9edddaa4-0c5a-429d-8743-1b8ca064dfae%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Django multiple model from one form submit

2014-02-19 Thread Henrique Oliveira
Hi there,

I have the model below:

class Ticket(models.Model):
REAL = 'R'
FREE = 'F'
TYPES = (
(REAL, 'Real'),
(FREE, 'Free'),
 )
   amount = models.DecimalField()
user = models.ForeignKey(User)


class Pick(models.Model):
ticket_id = models.ForeignKey(Ticket)
number = models.CharField(max_length=4)

Many Tickets can be created on the same submit depending on the ticket type.

how can do that

i have attached a mockup 

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d3d1cdf8-0097-4323-9a4f-660dfc8c7b84%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
<>

Re: Django multiple model from one form submit

2014-02-19 Thread Jonathan Querubina
You can use an admin custom insert form

With stackedinline


Jonathan Querubina

Diretor de Tecnologia
+55(12)98864-1594
www.phocus.com.br

> On Feb 19, 2014, at 19:24, Henrique Oliveira  
> wrote:
> 
> Hi there,
> 
> I have the model below:
> 
> class Ticket(models.Model):
> REAL = 'R'
> FREE = 'F'
> TYPES = (
> (REAL, 'Real'),
> (FREE, 'Free'),
>  )
>amount = models.DecimalField()
> user = models.ForeignKey(User)
> 
> 
> class Pick(models.Model):
> ticket_id = models.ForeignKey(Ticket)
> number = models.CharField(max_length=4)
> 
> Many Tickets can be created on the same submit depending on the ticket type.
> 
> how can do that
> 
> i have attached a mockup 
> 
> Cheers
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/d3d1cdf8-0097-4323-9a4f-660dfc8c7b84%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/834BB0F1-AFC5-4C20-A222-32650E0A7DD0%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Translated URL's

2014-02-19 Thread werefrog

Felipe,

Sorry, I'm quite busy these days.

Here is the beginning of something, but I'd prefer to avoid the 'myurl' 
function. I'm not a dev' so you'll probably jump looking at that.


The base idea was to use only 'mypatterns' for obtainning the same 
results we handwritten previously, including the ordering observation 
you did. However, I cannot currently figure how to modify the url call, 
that's why I had to use 'myurl'.


The following mess mostly butchered url and patterns functions normally 
used.


It needs testing and that's quite raw but I'll take a look this week-end 
probably. The don't think I handled 'prefix' variable how it should be 
but that's for waiting ;)


# urls.py

from django.conf.urls import patterns, include, url
from django.utils.translation import ugettext_lazy as _
from django.conf.urls.i18n import i18n_patterns
from imbadwithnamestoo.utils import mypatterns, myurl

urlpatterns = patterns('',
#
)
urlpatterns += mypatterns('',
myurl(_(r'^suporte/'), include('WebSuporte.urls') ),
)


# imbadwithnamestoo.utils

from django.conf import settings
from django.conf.urls import url
from django.utils.translation import activate, deactivate
from django.utils.translation import ugettext


def myurl(regex, view, kwargs=None, name=None, prefix=''):
return (regex, view, kwargs, name, prefix)

def mypatterns(prefix, *args):
pattern_list = []
for t in args:
# dealing with include or others
regex, view, kwargs, name, prefix = t

languages = [lang[0] for lang in settings.LANGUAGES]

if isinstance(view, (list,tuple)):
# For include(...) processing.
for lang in languages:
activate(lang)
translated_regex = ugettext(regex)
pattern_list.append(url(translated_regex, view, kwargs, 
None, prefix))

deactivate()
pattern_list.append(url(regex, view, kwargs, name, prefix))
else:
pattern_list.append(url(regex, view, kwargs, name, prefix))
for lang in languages:
activate(lang)
translated_regex = ugettext(regex)
pattern_list.append(url(translated_regex, view, kwargs, 
None, prefix))

deactivate()

return pattern_list

Regards,
Michel

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/53053AD7.6000105%40yahoo.fr.
For more options, visit https://groups.google.com/groups/opt_out.