Re: Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-21 Thread Russell Keith-Magee
On Thu, Aug 22, 2013 at 1:37 PM, Radomir Wojcik wrote:

>
> And I tried with both UTF8 and LATIN1 database encodings, both produce the
> same error:
>
>   List of databases
>Name|  Owner   | Encoding |   Collate   |Ctype|   Access
> privileg
> es
>
> ---+--+--+-+-+--
> -
>  mandala   | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
>  mandala3  | postgres | LATIN1   | C   | C   |
>
> I have a feeling that this is related to django + postgres as I noticed
> too that the login username used to be case insensitive but after the
> conversion is case sensitive.. strange. Is Postgres really that good? If I
> can't fix I will have to switch back to MySQL and wait for MariaDB to be
> officially supported...
>

Yes, PostgreSQL is that good. Without wanting to be too blunt, PostgreSQL
is a database; MySQL is a popular tool that can be used to store data.

It's difficult to say for certain what has gone wrong without knowing
exactly how you've exported your data. However, all indications suggest
that something in your conversion chain has gone wrong, and as a result,
you've got data that has been double converted, or is being interpreted as
ASCII when it's actually unicode content. If you put unicode content into a
PostgreSQL database that has been configured to use UTF-8, it handles it
fine. However, if you put in garbage, or you haven't configured PostgreSQL
to handle UTF-8 content, you can't expect it to work without problems.

The best way to track this down is to follow a single string from one
database to another. First, put a string that is known to be UTF-8 into
your PostgreSQL database, and make sure it comes out OK. Then, pick a row
in your MySQL database that has unicode content in it, and export it from
MySQL. Make sure the exported format has the content correctly encoded.
Then import into PostgreSQL; check that was has been imported correctly.
Once you've moved a single string from one database to another, you can
reproduce that process en masse for the rest of your database.

Yours,
Russ Magee %-)

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-21 Thread Radomir Wojcik

And I tried with both UTF8 and LATIN1 database encodings, both produce the 
same error:

  List of databases
   Name|  Owner   | Encoding |   Collate   |Ctype|   Access 
privileg
es   
---+--+--+-+-+--
-
 mandala   | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | 
 mandala3  | postgres | LATIN1   | C   | C   | 

I have a feeling that this is related to django + postgres as I noticed too 
that the login username used to be case insensitive but after the 
conversion is case sensitive.. strange. Is Postgres really that good? If I 
can't fix I will have to switch back to MySQL and wait for MariaDB to be 
officially supported...




















-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Can't decode french characters after switching to PostgrSQL from MySQL

2013-08-21 Thread Radomir Wojcik
my code worked fine up until I switched to PostgreSQL from MySQL. Now I am 
bombarded with these errors whenever I have french accents in my strings. 
My database is correctly configured with LATIN1 (as UTF8 didn't like the 
accents when trying to import them from MySQL, the default was UTF8).

My postgresql.conf has the right settings by the look of it:
client_encoding = latin1# encoding

# These settings are initialized by initdb, but they can be changed.
lc_messages = 'en_CA.iso88591'  # locale for system error 
message
# strings
lc_monetary = 'en_CA.iso88591' #en_US.UTF-8'# locale for monetary 
formatting
lc_numeric = 'en_CA.iso88591'   # locale for number 
formatting
lc_time = 'en_CA.iso88591' 

How do I switch this ascii decoder in django to a decoder that can handle 
french accents?

UnicodeDecodeError at /alarms/edit/100/

'ascii' codec can't decode byte 0xc3 in position 10: ordinal not in range(128)

Request Method:POSTRequest 
URL:https://mandala.cldssinc.com/alarms/edit/100/Django 
Version:1.5.2Exception Type:UnicodeDecodeErrorException Value:

'ascii' codec can't decode byte 0xc3 in position 10: ordinal not in range(128)

Exception Location:/var/web/mandala_env/mandala/alarms/models.py in 
__unicode__, line 21Python Executable:/var/web/mandala_env/bin/pythonPython 
Version:2.6.6Python Path:

['/var/web/mandala_env/mandala/mandala',
 '/var/web/mandala_env/mandala',
 '/var/web/mandala_env/bin',
 '/var/web/mandala_env/lib64/python26.zip',
 '/var/web/mandala_env/lib64/python2.6',
 '/var/web/mandala_env/lib64/python2.6/plat-linux2',
 '/var/web/mandala_env/lib64/python2.6/lib-tk',
 '/var/web/mandala_env/lib64/python2.6/lib-old',
 '/var/web/mandala_env/lib64/python2.6/lib-dynload',
 '/usr/lib64/python2.6',
 '/usr/lib/python2.6',
 '/var/web/mandala_env/lib/python2.6/site-packages']

Server time:
Thu, 22 Aug 2013 01:16:16 -0400






Thanks

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I create a script to fill in django admin login form and submit?

2013-08-21 Thread 7equivalents
Thank you so much! You really helped me. I went back and checked the source 
code sent to my browser and did indeed see, name = "this_is_the_login_form'.
I was using the "ID" rather than the "name". My weakness in html kicked me 
this time, thanks for lending a hand!






>
>
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re:

2013-08-21 Thread yati sagade
I think we all got it.


On Wed, Aug 21, 2013 at 11:52 PM, Roberto López López
wrote:

>  I got it as well.
>
>
>
>
> On 08/21/2013 07:50 PM, Mike Doroshenko II wrote:
>
> How/Why am I getting this? Has anyone else received this?
>
> To: django-users+unsubscr...@googlegroups.com
>
> On 08/21/2013 02:44 AM, Shahmi Junoh wrote:
>
>   Hi,
>
>  I would like to unsubscribe from getting the updates.
>
>  Thanks in advance.
>
>  Regards,
>  Shahmi
>  --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> --
> Mike Doroshenko, Junior Sys Admin
> TecKnoQuest inc.mi...@tecknoquest.comwww.tecknoquest.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.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
> --
>
> Roberto López López
> System Developer
> Parallab, Uni Computing+47 55584091
>
>  --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Yati Sagade

Software Engineer at mquotient 


Twitter: @yati_itay  | Github:
yati-sagade

Organizing member of TEDx EasternMetropolitanBypass
http://www.ted.com/tedx/events/4933
https://www.facebook.com/pages/TEDx-EasternMetropolitanBypass/337763226244869

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I create a script to fill in django admin login form and submit?

2013-08-21 Thread Kelvin Wong
I've used Requests in the past.

All I did was load the page in Chrome and then I looked at what was being 
sent and compared it to what your script was sending. When I added the 
missing key it worked.

Trial and error. :)

K



On Wednesday, August 21, 2013 8:48:16 AM UTC-7, 7equiv...@gmail.com wrote:
>
> How did you know that that was the name of the form? When I went to 
> django.contrib.auth.forms, it seemed the form name was AuthenticationForm, 
> and when I used view source in a browser it looked like the form was named 
> login-form. How could one know the form was named 'this_is_the_login_form'?
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django ORM: default value from sql query

2013-08-21 Thread Marcin Szamotulski
I should be more specific:  I cannot because the query depends on the
object instance:

class MyModel(models.Models):

fkey = models.ForeignKey(..., null=False)

count = 
models.PosotiveIntegerField(default=lambda:MyModel.objects.filter(fkey_id= _?_ 
).count())


where _?_ should be the models's instance fkey attribute.


On 17:05 Wed 21 Aug , Simon Charette wrote:
> You can achieve this by setting a callable default value [1] on you field:
> 
> class MyModel(models.Model):
> count = 
> models.PositiveIntegerField(default=lambda:MyModel.objects.count())
> 
> [1] 
> https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.default
> Le mercredi 21 août 2013 18:49:48 UTC-4, Marcin Szamotulski a écrit :
> >
> > Dear Django users, 
> >
> > I am would like to set a default value on a model's field as a result of 
> > a simple query.  Something that in SQLAlchemy is done like that: 
> > http://docs.sqlalchemy.org/en/rel_0_7/core/schema.html#sql-expressions 
> >
> > Specifically I want to count some objects in the database and set this 
> > count as the default value.  I know that this can be done in two steps 
> > first find the value then set it, but I would like to have it done 
> > automatically. 
> >
> > Best regards, 
> > Marcin 
> >
> 
> -- 
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Using an external Server to serve Static files - Development Server

2013-08-21 Thread Kelvin Wong
This is how I do it.

In settings.py:

STATIC_ROOT = '/home/user/app/site_media/static/'  # Generated files here 
from 'manage.py collectstatic'

STATIC_URL = 'http://static.example.com/static/'

In templates:

{% load staticfiles %}

...



Produces:

http://static.example.com/static/myapp/stylesheets/app.css; 
rel="stylesheet" type="text/css">

If static.example.com is behind Nginx this is in your static server conf 
file:

# Nginx staticfiles setting

location /site_media/ {
  alias /home/user/app/site_media/;
}

This is a made up example, but the real thing is close to it.

K

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Using an external Server to serve Static files - Development Server

2013-08-21 Thread Ideo Rex
{% load staticfiles %}



This is just for my css file (there are other categories under lifestream.

server: https://my.site.com/DJStatic/static/livestream/css/style.css

On Wednesday, August 21, 2013 6:18:37 PM UTC-7, Nikolas Stevenson-Molnar 
wrote:
>
> That should work... how are you referencing your static files from your 
> templates? 
>
> _Nik 
>
> On 8/21/2013 6:09 PM, Ideo Rex wrote: 
> > Hello, 
> > I have a different request that I couldn't find anywhere else on the 
> > internet. I'm an intern who has built a Django Web Application for my 
> > project (basically a large experiment). The cite will never leave 
> > development, but I'm holding my static files and templates on another 
> > server. I want Django to look for static files on this website. 
> > 
> > Currently my project is 'livestream', in livestream there are two sub 
> > directories: 'templates' & 'static' 
> > On my server I have https://my.site.com/DJStatic/ - inside of DJStatic 
> > are two sub directories: 'templates' & 'static' 
> > 
> > How do I tell django to look in the server for the static files rather 
> > than the local directory? 
> > 
> > 
> > Tests: 
> > I have removed the local static files and set STATIC_URL : 
> > https://my.site.com/DJStatic/static/, but it doesn't work this way. 
> > Any Ideas on how to fix this? 
> > 
> > Thanks 
> > -- 
> > 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...@googlegroups.com . 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > Visit this group at http://groups.google.com/group/django-users. 
> > 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Using an external Server to serve Static files - Development Server

2013-08-21 Thread Nikolas Stevenson-Molnar
That should work... how are you referencing your static files from your
templates?

_Nik

On 8/21/2013 6:09 PM, Ideo Rex wrote:
> Hello,
> I have a different request that I couldn't find anywhere else on the
> internet. I'm an intern who has built a Django Web Application for my
> project (basically a large experiment). The cite will never leave
> development, but I'm holding my static files and templates on another
> server. I want Django to look for static files on this website.
>
> Currently my project is 'livestream', in livestream there are two sub
> directories: 'templates' & 'static'
> On my server I have https://my.site.com/DJStatic/ - inside of DJStatic
> are two sub directories: 'templates' & 'static'
>
> How do I tell django to look in the server for the static files rather
> than the local directory?
>
>
> Tests:
> I have removed the local static files and set STATIC_URL :
> https://my.site.com/DJStatic/static/, but it doesn't work this way.
> Any Ideas on how to fix this?
>
> Thanks
> -- 
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Using an external Server to serve Static files - Development Server

2013-08-21 Thread Ideo Rex
Hello,
I have a different request that I couldn't find anywhere else on the 
internet. I'm an intern who has built a Django Web Application for my 
project (basically a large experiment). The cite will never leave 
development, but I'm holding my static files and templates on another 
server. I want Django to look for static files on this website.

Currently my project is 'livestream', in livestream there are two sub 
directories: 'templates' & 'static'
On my server I have https://my.site.com/DJStatic/ - inside of DJStatic are 
two sub directories: 'templates' & 'static'

How do I tell django to look in the server for the static files rather than 
the local directory?


Tests:
I have removed the local static files and set STATIC_URL : 
https://my.site.com/DJStatic/static/, but it doesn't work this way. Any 
Ideas on how to fix this?

Thanks

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django ORM: default value from sql query

2013-08-21 Thread Simon Charette
You can achieve this by setting a callable default value [1] on you field:

class MyModel(models.Model):
count = 
models.PositiveIntegerField(default=lambda:MyModel.objects.count())

[1] 
https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.default
Le mercredi 21 août 2013 18:49:48 UTC-4, Marcin Szamotulski a écrit :
>
> Dear Django users, 
>
> I am would like to set a default value on a model's field as a result of 
> a simple query.  Something that in SQLAlchemy is done like that: 
> http://docs.sqlalchemy.org/en/rel_0_7/core/schema.html#sql-expressions 
>
> Specifically I want to count some objects in the database and set this 
> count as the default value.  I know that this can be done in two steps 
> first find the value then set it, but I would like to have it done 
> automatically. 
>
> Best regards, 
> Marcin 
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Dynamic increasing choices object

2013-08-21 Thread Simon Charette
Not really Django related but you can achieve it by doing the following:

WEIGHTS = tuple(
(weight, "%dkg" % weight) for weight in range(40, 251)
)

Le mercredi 21 août 2013 18:16:59 UTC-4, Gerd Koetje a écrit :
>
>
> How do i automatic increase this from 40 tot 250kg
> its a choices field inside of models.py
>
> WEIGHTS = (
>
> ('40','40kg'),
>
> ('41','41kg'),  
>
> )
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Django ORM: default value from sql query

2013-08-21 Thread Marcin Szamotulski
Dear Django users,

I am would like to set a default value on a model's field as a result of
a simple query.  Something that in SQLAlchemy is done like that:
http://docs.sqlalchemy.org/en/rel_0_7/core/schema.html#sql-expressions

Specifically I want to count some objects in the database and set this
count as the default value.  I know that this can be done in two steps
first find the value then set it, but I would like to have it done
automatically.

Best regards,
Marcin

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Dynamic increasing choices object

2013-08-21 Thread Gerd Koetje
i used php to solve my issue for now, builded the object and copy pasted it





   ('',''),



-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Dynamic increasing choices object

2013-08-21 Thread Gerd Koetje

How do i automatic increase this from 40 tot 250kg
its a choices field inside of models.py

WEIGHTS = (

('40','40kg'),

('41','41kg'),  

)

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Populate choices from model

2013-08-21 Thread Rafael E. Ferrero
you can read this too
http://www.protocolostomy.com/2009/08/21/lessons-learned-while-creating-a-generic-taxonomy-app-for-django/

https://github.com/bkjones/django-taxonomy


2013/8/21 Gerd Koetje 

> example of what im doing
>
> 
>
> from django.db import models
>
> from django.contrib.auth.models import User
>
> from django.contrib.sites.models import Site
>
>
>
> # Create your models here.
>
>
>
>
> # formulier keuze databases
>
>
> class Kleurogen_data (models.Model):
>
> name = models.CharField(max_length=255)
>
>
>
> def __unicode__(self):
>
> return self.name
>
>
> class Haarkleur_data (models.Model):
>
> name = models.CharField(max_length=255)
>
>
>
> def __unicode__(self):
>
> return self.name
>
>
>
> class Lengtehaar_data (models.Model):
>
> name = models.CharField(max_length=255)
>
>
>
> def __unicode__(self):
>
> return self.name
>
>
>
> class Landen (models.Model):
>
> slug = models.CharField(max_length=255)
>
> name = models.CharField(max_length=255)
>
>
>
> def __unicode__(self):
>
> return self.name
>
>
> class Regio (models.Model):
>
> slug = models.CharField(max_length=255)
>
> name = models.CharField(max_length=255)
>
> land = models.ForeignKey(Landen)
>
>
>
> def __unicode__(self):
>
> return self.name
>
>
>
>
> # sitedeals
>
>
> class Sitedetails(models.Model):
>
> JANEE = (
>
> ('Y','Ja'),
>
> ('N','Nee'),
>
> )
>
>
>
> TAAL = (
>
> ('Nederlands','Nederlands'),
>
> ('Engels','Engels'),
>
> )
>
>
>
> site = models.ForeignKey(Site)
>
> pub_date = models.DateTimeField('date published')
>
>
>
> sitetekst = models.TextField()
>
> beschrijving = models.TextField()
>
> keywords = models.TextField()
>
> google = models.TextField()
>
>
>
> adult = models.CharField(max_length=2, choices=JANEE, default='N')
>
> sitetaal = models.CharField(max_length=2, choices=TAAL, default=
> 'Nederlands')
>
>
>
> dailxsid = models.CharField(max_length=255)
>
> smtploc = models.CharField(max_length=255)
>
> smtpuser = models.CharField(max_length=255)
>
> smtppass = models.CharField(max_length=255)
>
>
>
> ontvangen = models.IntegerField(default=0)
>
> verzonden = models.IntegerField(default=0)
>
> aanmeldingen = models.IntegerField(default=0)
>
> afmeldingen = models.IntegerField(default=0)
>
> views = models.IntegerField(default=0)
>
> profielen = models.IntegerField(default=0)
>
>
>
>
>
> class Meta:
>
> unique_together = ["site"]
>
> verbose_name_plural = "Sitedetails"
>
> app_label = 'sites'
>
>
>
> def __unicode__(self):
>
> return self.keywords
>
>
>
>
>
>
>
> class Profielen(models.Model):
>
> JANEE = (
>
> ('Y','Ja'),
>
> ('N','Nee'),
>
> )
>
>
>
> GENDER = (
>
> ('Man','Man'),
>
> ('Vrouw','Vrouw'),
>
> )
>
>
>
>
>
>
>
> profielnaam = models.CharField(max_length=255)
>
> leeftijd = models.CharField(max_length=3)
>
>
>
> issoort = models.CharField(max_length=10, choices=GENDER, default=
> 'Man')
>
> zoektsoort = models.CharField(max_length=10, choices=GENDER, default=
> 'Vrouw')
>
> adult = models.CharField(max_length=2, choices=JANEE, default='N')
>
> partner = models.CharField(max_length=2, choices=JANEE, default='N')
>
>
>
> regio = models.ForeignKey(Regio, default='Amsterdam')
>
> land = models.ForeignKey(Landen, default='Nederland')
>
>
>
>
>
> kleurogen = models.ManyToManyField(Kleurogen_data, blank=False, null=
> False)
>
> haarkleur = models.ManyToManyField(Haarkleur_data, blank=False, null=
> False)
>
> lengtehaar = models.ManyToManyField(Lengtehaar_data, blank=False,
> null=False)
>
>
>
> postuur = models.CharField(max_length=255)
>
> gewicht = models.CharField(max_length=255)
>
> afkomst = models.CharField(max_length=255)
>
> gebjaar = models.CharField(max_length=255)
>
> gebmaand = models.CharField(max_length=255)
>
> gebdag = models.CharField(max_length=255)
>
> lengte = models.CharField(max_length=255)
>
> burgelijkestaat = models.CharField(max_length=255)
>
> opleidingsniveau = models.CharField(max_length=255)
>
> levensstijl = models.CharField(max_length=255)
>
> ikvoelme = models.CharField(max_length=255)
>
> inter = models.CharField(max_length=255)
>
> haarstijl = models.CharField(max_length=255)
>
> relatie = models.CharField(max_length=255)
>
> cupmaat = models.CharField(max_length=255)
>
> geaardheid = models.CharField(max_length=255)
>
> sterrenbeeld = models.CharField(max_length=255)
>
> uiterlijkekenmerken = models.TextField()
>
> belangstellingvoor = models.TextField()
>
> beschrijving = models.TextField()
>
> omschrijving = models.TextField()
>
> algemenevoorkeuren = models.TextField()
>
> sexvoorkeuren = models.TextField()
>
> 

Re: Populate choices from model

2013-08-21 Thread Gerd Koetje
example of what im doing



from django.db import models

from django.contrib.auth.models import User

from django.contrib.sites.models import Site



# Create your models here.


   

# formulier keuze databases


class Kleurogen_data (models.Model):

name = models.CharField(max_length=255)



def __unicode__(self):

return self.name


class Haarkleur_data (models.Model):

name = models.CharField(max_length=255)



def __unicode__(self):

return self.name



class Lengtehaar_data (models.Model):

name = models.CharField(max_length=255)



def __unicode__(self):

return self.name



class Landen (models.Model):

slug = models.CharField(max_length=255)

name = models.CharField(max_length=255)



def __unicode__(self):

return self.name


class Regio (models.Model):

slug = models.CharField(max_length=255)

name = models.CharField(max_length=255)

land = models.ForeignKey(Landen)



def __unicode__(self):

return self.name




# sitedeals


class Sitedetails(models.Model):

JANEE = (

('Y','Ja'),

('N','Nee'),  

)



TAAL = (

('Nederlands','Nederlands'),

('Engels','Engels'),  

)



site = models.ForeignKey(Site)

pub_date = models.DateTimeField('date published')



sitetekst = models.TextField()

beschrijving = models.TextField()

keywords = models.TextField()

google = models.TextField()



adult = models.CharField(max_length=2, choices=JANEE, default='N')

sitetaal = models.CharField(max_length=2, choices=TAAL, default=
'Nederlands')



dailxsid = models.CharField(max_length=255)   

smtploc = models.CharField(max_length=255)

smtpuser = models.CharField(max_length=255)

smtppass = models.CharField(max_length=255)



ontvangen = models.IntegerField(default=0)

verzonden = models.IntegerField(default=0)

aanmeldingen = models.IntegerField(default=0)

afmeldingen = models.IntegerField(default=0)

views = models.IntegerField(default=0)

profielen = models.IntegerField(default=0)





class Meta:

unique_together = ["site"]

verbose_name_plural = "Sitedetails"

app_label = 'sites'



def __unicode__(self):

return self.keywords

  

  

  

class Profielen(models.Model):

JANEE = (

('Y','Ja'),

('N','Nee'),  

)



GENDER = (

('Man','Man'),

('Vrouw','Vrouw'),  

)



  



profielnaam = models.CharField(max_length=255)

leeftijd = models.CharField(max_length=3)



issoort = models.CharField(max_length=10, choices=GENDER, default='Man')

zoektsoort = models.CharField(max_length=10, choices=GENDER, default=
'Vrouw')

adult = models.CharField(max_length=2, choices=JANEE, default='N')

partner = models.CharField(max_length=2, choices=JANEE, default='N')



regio = models.ForeignKey(Regio, default='Amsterdam')

land = models.ForeignKey(Landen, default='Nederland')





kleurogen = models.ManyToManyField(Kleurogen_data, blank=False, null=
False)

haarkleur = models.ManyToManyField(Haarkleur_data, blank=False, null=
False)

lengtehaar = models.ManyToManyField(Lengtehaar_data, blank=False, null=
False)



postuur = models.CharField(max_length=255)

gewicht = models.CharField(max_length=255)

afkomst = models.CharField(max_length=255)

gebjaar = models.CharField(max_length=255)

gebmaand = models.CharField(max_length=255)

gebdag = models.CharField(max_length=255)

lengte = models.CharField(max_length=255)

burgelijkestaat = models.CharField(max_length=255)

opleidingsniveau = models.CharField(max_length=255)

levensstijl = models.CharField(max_length=255)

ikvoelme = models.CharField(max_length=255)

inter = models.CharField(max_length=255)

haarstijl = models.CharField(max_length=255)

relatie = models.CharField(max_length=255)

cupmaat = models.CharField(max_length=255)

geaardheid = models.CharField(max_length=255)

sterrenbeeld = models.CharField(max_length=255)   

uiterlijkekenmerken = models.TextField()

belangstellingvoor = models.TextField()

beschrijving = models.TextField()

omschrijving = models.TextField()

algemenevoorkeuren = models.TextField()

sexvoorkeuren = models.TextField()

bdsmvoorkeuren = models.TextField()

sexkenmerken = models.TextField()

belangstelling = models.TextField()

omschrijvingengels = models.TextField()

beschrijvingengels = models.TextField()

likes = models.IntegerField(default=0)

views = models.IntegerField(default=0)

user = models.ForeignKey(User) 

 
 class Meta:

   verbose_name_plural = "Profielen"


def __unicode__(self):
return 

Re: Populate choices from model

2013-08-21 Thread Gerd Koetje
example of what im doing so far

from django.db import models

from django.contrib.auth.models import User

from django.contrib.sites.models import Site



# Create your models here.


   

# formulier keuze databases


class Kleurogen_data (models.Model):

name = models.CharField(max_length=255)



def __unicode__(self):

return self.name


class Haarkleur_data (models.Model):

name = models.CharField(max_length=255)



def __unicode__(self):

return self.name



class Lengtehaar_data (models.Model):

name = models.CharField(max_length=255)



def __unicode__(self):

return self.name



class Landen (models.Model):

slug = models.CharField(max_length=255)

name = models.CharField(max_length=255)



def __unicode__(self):

return self.name


class Regio (models.Model):

slug = models.CharField(max_length=255)

name = models.CharField(max_length=255)

land = models.ForeignKey(Landen)



def __unicode__(self):

return self.name




# sitedeals


class Sitedetails(models.Model):

JANEE = (

('Y','Ja'),

('N','Nee'),  

)



TAAL = (

('Nederlands','Nederlands'),

('Engels','Engels'),  

)



site = models.ForeignKey(Site)

pub_date = models.DateTimeField('date published')



sitetekst = models.TextField()

beschrijving = models.TextField()

keywords = models.TextField()

google = models.TextField()



adult = models.CharField(max_length=2, choices=JANEE, default='N')

sitetaal = models.CharField(max_length=2, choices=TAAL, default=
'Nederlands')



dailxsid = models.CharField(max_length=255)   

smtploc = models.CharField(max_length=255)

smtpuser = models.CharField(max_length=255)

smtppass = models.CharField(max_length=255)



ontvangen = models.IntegerField(default=0)

verzonden = models.IntegerField(default=0)

aanmeldingen = models.IntegerField(default=0)

afmeldingen = models.IntegerField(default=0)

views = models.IntegerField(default=0)

profielen = models.IntegerField(default=0)





class Meta:

unique_together = ["site"]

verbose_name_plural = "Sitedetails"

app_label = 'sites'



def __unicode__(self):

return self.keywords

  

  

  

class Profielen(models.Model):

JANEE = (

('Y','Ja'),

('N','Nee'),  

)



GENDER = (

('Man','Man'),

('Vrouw','Vrouw'),  

)



  



profielnaam = models.CharField(max_length=255)

leeftijd = models.CharField(max_length=3)



issoort = models.CharField(max_length=10, choices=GENDER, default='Man')

zoektsoort = models.CharField(max_length=10, choices=GENDER, default=
'Vrouw')

adult = models.CharField(max_length=2, choices=JANEE, default='N')

partner = models.CharField(max_length=2, choices=JANEE, default='N')



regio = models.ForeignKey(Regio, default='Amsterdam')

land = models.ForeignKey(Landen, default='Nederland')





kleurogen = models.ManyToManyField(Kleurogen_data, blank=False, null=
False)

haarkleur = models.ManyToManyField(Haarkleur_data, blank=False, null=
False)

lengtehaar = models.ManyToManyField(Lengtehaar_data, blank=False, null=
False)



postuur = models.CharField(max_length=255)

gewicht = models.CharField(max_length=255)

afkomst = models.CharField(max_length=255)

gebjaar = models.CharField(max_length=255)

gebmaand = models.CharField(max_length=255)

gebdag = models.CharField(max_length=255)

lengte = models.CharField(max_length=255)

burgelijkestaat = models.CharField(max_length=255)

opleidingsniveau = models.CharField(max_length=255)

levensstijl = models.CharField(max_length=255)

ikvoelme = models.CharField(max_length=255)

inter = models.CharField(max_length=255)

haarstijl = models.CharField(max_length=255)

relatie = models.CharField(max_length=255)

cupmaat = models.CharField(max_length=255)

geaardheid = models.CharField(max_length=255)

sterrenbeeld = models.CharField(max_length=255)   

uiterlijkekenmerken = models.TextField()

belangstellingvoor = models.TextField()

beschrijving = models.TextField()

omschrijving = models.TextField()

algemenevoorkeuren = models.TextField()

sexvoorkeuren = models.TextField()

bdsmvoorkeuren = models.TextField()

sexkenmerken = models.TextField()

belangstelling = models.TextField()

omschrijvingengels = models.TextField()

beschrijvingengels = models.TextField()

likes = models.IntegerField(default=0)

views = models.IntegerField(default=0)

user = models.ForeignKey(User) 



class Meta:

verbose_name_plural = "Profielen"


def __unicode__(self):

return 

Re: Populate choices from model

2013-08-21 Thread Rafael E. Ferrero
I design a model structure to persist restrictions to a selectable category
(i dont say that its ok... its for shore that can do a lot of
improvements), and make a module to admin categories with that if i choose
some category to my contact first i check if i really can add that category
to my contact in base of a restriction model.

Let me give you an example... think in contact of a enterprise... supliers,
customers, employees... if a contact have employees category he cant have a
suplier category too


The model its something like this:

Categories
Id_category (PK)
CategoryName

Category_Parents
Id_CategoryParent (PK)
Id_Category (fk to Categories.Id_Category)
Id_Parent (fk to Categories.Id_Category)

Categories_Restrictions
Id_CategoryRestriction
Id_CategoryChoosed
Id_CategoryRestricted
Restriction (choice of Y or N)*
*if choose 'Y' means that your entity must already has added a
id_categoryRestricted to permit choose id_categoryChoosed
*if choose 'N' means that if your entity has id_CategoryRestricted added
you can permit add id_categoryChoosed

Relationships (or use choice of 'and', 'or, 'xor', etc)
Id_Relationship (PK)
RelationshipName
RelationshipDescription

Groups
Id_Groups (PK)
GroupName
Id_Relationship (fk to Relationships.Id_Relationship)

Categories_Groups
Id_CategoryGroup (PK)
Id_Category (fk to Categories.Id_Category)
Id_Group (fk to Groups.Id_Groups)

InterGroups_Relations
Id_InterGroupsRelations
InterGroupRelationName
Id_Group1 (fk to Groups.Id_Groups)
Id_Group2 (fk to Groups.Id_Groups)
Id_Relationship (fk to Relationships.Id_Relationship)

With this you can add categories, group them and make groups of groups. The
elements of a group can have restrictions between them for example the
categories of some group can have an xor relation, so only one of them can
be choosed for a entity.
When you choose a Category for your entity first make a check if have some
restritction if pass every test then you make add that category.

first check for Categories_Restrictions
then check for groups restrictions
then check for intergroups restrictions

its complicated, i know, also i know that can be better than that... its my
little help :P

See ya (sorry my bad english too)



2013/8/21 Gerd Koetje 

> i would vote for the m2m model, but i think i loose it there a bit
>
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Rafael E. Ferrero
Claro: (03562) 15514856

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How can I get value from a FK model?

2013-08-21 Thread Fellipe Henrique
To add in my last comment, I need the Query bring me all related fields in 
all models.. all fields in one SQL, to get this field value in my template.

Regards,

Em quarta-feira, 21 de agosto de 2013 17h52min50s UTC-3, Fellipe Henrique 
escreveu:
>
> Ok, I have make a mistake, the correct is idpedido is only FK. and 
> 'iditenspedido' is a PK, the correct model is this:
>
> class ItensPedido(models.Model):
> iditenspedido = models.IntegerField('Código', primary_key=True, 
> default=-1)
> idpedido = models.ForeignKey('Pedido', db_column='idpedido', 
> default=-1)
> idproduto = models.ForeignKey('Produto', db_column='idproduto')
> preco = models.DecimalField(u'Vlr. Total', max_digits=18, 
> decimal_places=4,
> null=False, default=0)
> quantidade = models.DecimalField(u'Vlr. Total', max_digits=18,
>  decimal_places=4, null=False, 
> default=0)
> precototal = models.DecimalField(u'Vlr. Total', max_digits=18,
>  decimal_places=4, null=False, 
> default=0)
>
>
> I can't let's django create PK, because, this is a legacy database used by 
> your Delphi ERP software, and the table was made on this way ( it's crazy I 
> know, but I can't change anything in database now ).
>
> Thanks again.
>
> Em quarta-feira, 21 de agosto de 2013 17h41min45s UTC-3, Daniel Roseman 
> escreveu:
>>
>> On Wednesday, 21 August 2013 20:53:36 UTC+1, Fellipe Henrique wrote:
>>
>>> Hi,
>>>
>>> I got this models: http://pastebin.com/w2TmyLzt
>>>
>>> First: I used db_columns because I used a legacy database from company 
>>> ERP.
>>>
>>> I try to get, in my template the "descricao" field, in my "mercadoria" 
>>> model. but I have in my "itenspedido" only "idproduto" not "idmercadoria".
>>>
>>> My question is: how can I get "descricao" field from "mercadoria" model 
>>> in my formset? 
>>>
>>> I tried {{ itens.idproduto.idmercadoria.descricao }} , {{ 
>>> itens.idproduto.idmercadoria.descricao.value }}   and not work.
>>>
>>> P.S.: I use modelForm as default form, like this:
>>>
>>> class PedidoItensForm(ModelForm):
>>> class Meta:
>>> model = ItensPedido
>>>
>>> Thanks,
>>>
>>> Regards,
>>>
>>
>> You have set `idpedido` as the primary key in the ItensPedido model. 
>> Primary keys are not modifiable so do not show up in forms. It makes no 
>> sense to that that as the PK in the joining table anyway: PK implies 
>> uniqueness, which means you can only have one ItensPedido per Pedido, which 
>> defeats the whole purpose of the many-to-many relationship.
>>
>> Remove the `primary_key=True` attribute and let Django create its own PK 
>> column. 
>> --
>> DR.
>>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How can I get value from a FK model?

2013-08-21 Thread Fellipe Henrique
Ok, I have make a mistake, the correct is idpedido is only FK. and 
'iditenspedido' is a PK, the correct model is this:

class ItensPedido(models.Model):
iditenspedido = models.IntegerField('Código', primary_key=True, 
default=-1)
idpedido = models.ForeignKey('Pedido', db_column='idpedido', default=-1)
idproduto = models.ForeignKey('Produto', db_column='idproduto')
preco = models.DecimalField(u'Vlr. Total', max_digits=18, 
decimal_places=4,
null=False, default=0)
quantidade = models.DecimalField(u'Vlr. Total', max_digits=18,
 decimal_places=4, null=False, 
default=0)
precototal = models.DecimalField(u'Vlr. Total', max_digits=18,
 decimal_places=4, null=False, 
default=0)


I can't let's django create PK, because, this is a legacy database used by 
your Delphi ERP software, and the table was made on this way ( it's crazy I 
know, but I can't change anything in database now ).

Thanks again.

Em quarta-feira, 21 de agosto de 2013 17h41min45s UTC-3, Daniel Roseman 
escreveu:
>
> On Wednesday, 21 August 2013 20:53:36 UTC+1, Fellipe Henrique wrote:
>
>> Hi,
>>
>> I got this models: http://pastebin.com/w2TmyLzt
>>
>> First: I used db_columns because I used a legacy database from company 
>> ERP.
>>
>> I try to get, in my template the "descricao" field, in my "mercadoria" 
>> model. but I have in my "itenspedido" only "idproduto" not "idmercadoria".
>>
>> My question is: how can I get "descricao" field from "mercadoria" model 
>> in my formset? 
>>
>> I tried {{ itens.idproduto.idmercadoria.descricao }} , {{ 
>> itens.idproduto.idmercadoria.descricao.value }}   and not work.
>>
>> P.S.: I use modelForm as default form, like this:
>>
>> class PedidoItensForm(ModelForm):
>> class Meta:
>> model = ItensPedido
>>
>> Thanks,
>>
>> Regards,
>>
>
> You have set `idpedido` as the primary key in the ItensPedido model. 
> Primary keys are not modifiable so do not show up in forms. It makes no 
> sense to that that as the PK in the joining table anyway: PK implies 
> uniqueness, which means you can only have one ItensPedido per Pedido, which 
> defeats the whole purpose of the many-to-many relationship.
>
> Remove the `primary_key=True` attribute and let Django create its own PK 
> column. 
> --
> DR.
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How can I get value from a FK model?

2013-08-21 Thread Daniel Roseman
On Wednesday, 21 August 2013 20:53:36 UTC+1, Fellipe Henrique wrote:

> Hi,
>
> I got this models: http://pastebin.com/w2TmyLzt
>
> First: I used db_columns because I used a legacy database from company ERP.
>
> I try to get, in my template the "descricao" field, in my "mercadoria" 
> model. but I have in my "itenspedido" only "idproduto" not "idmercadoria".
>
> My question is: how can I get "descricao" field from "mercadoria" model in 
> my formset? 
>
> I tried {{ itens.idproduto.idmercadoria.descricao }} , {{ 
> itens.idproduto.idmercadoria.descricao.value }}   and not work.
>
> P.S.: I use modelForm as default form, like this:
>
> class PedidoItensForm(ModelForm):
> class Meta:
> model = ItensPedido
>
> Thanks,
>
> Regards,
>

You have set `idpedido` as the primary key in the ItensPedido model. 
Primary keys are not modifiable so do not show up in forms. It makes no 
sense to that that as the PK in the joining table anyway: PK implies 
uniqueness, which means you can only have one ItensPedido per Pedido, which 
defeats the whole purpose of the many-to-many relationship.

Remove the `primary_key=True` attribute and let Django create its own PK 
column. 
--
DR.

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


How can I get value from a FK model?

2013-08-21 Thread Fellipe Henrique
Hi,

I got this models: http://pastebin.com/w2TmyLzt

First: I used db_columns because I used a legacy database from company ERP.

I try to get, in my template the "descricao" field, in my "mercadoria" 
model. but I have in my "itenspedido" only "idproduto" not "idmercadoria".

My question is: how can I get "descricao" field from "mercadoria" model in 
my formset? 

I tried {{ itens.idproduto.idmercadoria.descricao }} , {{ 
itens.idproduto.idmercadoria.descricao.value }}   and not work.

P.S.: I use modelForm as default form, like this:

class PedidoItensForm(ModelForm):
class Meta:
model = ItensPedido

Thanks,

Regards,

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Populate choices from model

2013-08-21 Thread Gerd Koetje
i would vote for the m2m model, but i think i loose it there a bit

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Populate choices from model

2013-08-21 Thread Rafael E. Ferrero
In djangoproject link its this example...

MEDIA_CHOICES = (
('Audio', (
('vinyl', 'Vinyl'),
('cd', 'CD'),
)
),
('Video', (
('vhs', 'VHS Tape'),
('dvd', 'DVD'),
)
),
('unknown', 'Unknown'),
)

Maybe you can use something like this:

YOUR_CHOICES = (
   ('haircolor', (
   ('blond', 'Blond'),
   ('black', 'Black),
)
   ),

   ('skincolor', (
('white', 'White'),
('black', 'Black'),
)
   ),

   ('Gender', (
('male', 'Male'),
('female', 'Female'),
)
   ),
)

However, if you need dinamic choices use foreignkeys, if you need to many
foreignkeys for your choices why not think in categories or tags... so
design a m2m model

On my work have to catalog business contacts... i design a Contacts Model,
a Categories Model and a model in the middle so a Contact can have one or
more Categories.
Lets say that John Doe can have the next list of categories 'Brown Hair
Color', 'White Skin Color', 'Blue Eyes Color', 'Male Sex'...




2013/8/21 Gerd Koetje 

> im building a prety complicated user detail form with all kinds of fields,
> like:  gender,haircolor,skincolor
>
> some fields have to become dropdowns with only 1 choise out of many
> and some fields have to become multiple select fields with alot of choise
> (multiple choises allowed)
> I was trying to use 1 model that holds all the values for each field, but
> it seem to only work if i make a model for each field values
>
> the dropdowns seem to work ok with foreignkey
>
>  --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Rafael E. Ferrero
Claro: (03562) 15514856

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django performance compared to other web frameworks

2013-08-21 Thread Urs Beerli
Hi Alex

Thanks a lot for your considerable answer. Yeah, I probably can not avoid
it to (pre-) build up my own 'test' environment and check the performance
for my needs.

Cheers
-Urs
Am 21.08.2013 19:39 schrieb "Alex Mandel" :

> On 08/21/2013 10:10 AM, urs.beerli wrote:
> > Hi folks!
> >
> > I am pretty new to Django and what I have seen so far is very nice, I
> like
> > it a lot! But one of the most important things to me of a web framework
> is
> > the performance. If you take a look at:
> > http://www.techempower.com/benchmarks/#section=data-r6=i7=update
> > Django scores not that good (almost in every test). What are the reasons?
> >
> > Thanks
> > - Urs
> >
>
> Interesting question. Of course all benchmarks tend to be quite
> subjective as to testing strengths vs weakness. Some things I see, for
> django they used Postgres but for everything else they used Mysql and
> its not clear to me if those DB hits are cold start or not. We also have
> no idea if the indexes are the same, what tables types are in use and I
> assume the db configuration is stock.
>
> Wsgi they used gunicorn, but we have no idea the configuration of it and
> UWSGI is considered much faster than gunicorn (which is actually
> considered reasonably faster than apache mod wsgi)
>
> Also you need to compare only frameworks of the same type, Django's
> strength is in its completeness, of course some other frameworks will be
> faster because they are simpler. Many people consider Rails the biggest
> competitor to Django (feature and usage wise), if you limit your
> comparison to that Django looks quite good.
>
> The reality is you need to make a django app for yourself and see if it
> handles the load you want it to handle fast enough for you. At that
> point then look for something else. If all your page returns are fast
> enough that the user doesn't really notice and it can handle the number
> of concurrent users you want, that's all that really matters.
>
> If you really care about it just being as fast as possible, you should
> probably be writing it all from scratch or in a minimal framework with
> compile optimized code (C++ perhaps).
>
> Enjoy,
> Alex
>
> --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re:

2013-08-21 Thread Roberto López López
I got it as well.



On 08/21/2013 07:50 PM, Mike Doroshenko II wrote:
> How/Why am I getting this? Has anyone else received this?
>
> To: django-users+unsubscr...@googlegroups.com
> On 08/21/2013 02:44 AM, Shahmi Junoh wrote:
>> Hi,
>>
>> I would like to unsubscribe from getting the updates.
>>
>> Thanks in advance.
>>
>> Regards,
>> Shahmi
>> -- 
>> 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.
>> For more options, visit https://groups.google.com/groups/opt_out.
>
> --
> Mike Doroshenko, Junior Sys Admin
> TecKnoQuest Inc.
> mi...@tecknoquest.com
> www.tecknoquest.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.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to sync database and/or discard/disable cache?

2013-08-21 Thread Javier Guerra Giraldez
On Tue, Aug 20, 2013 at 11:17 PM, Dig  wrote:
> These 2 situation not 100% happened (but > 30%), I guess it caused some
> cache (django cache or mysql cache).


AFAIK, there's no "django cache".  so i'm guessing some transaction
mess.  maybe in that 30% cases some queries are done by different
processes and some transaction isn't correctly closed, so the second
process still sees the record A.



-- 
Javier

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re:

2013-08-21 Thread Mike Doroshenko II

How/Why am I getting this? Has anyone else received this?

To: django-users+unsubscr...@googlegroups.com

On 08/21/2013 02:44 AM, Shahmi Junoh wrote:

Hi,

I would like to unsubscribe from getting the updates.

Thanks in advance.

Regards,
Shahmi
--
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.
For more options, visit https://groups.google.com/groups/opt_out.


--
Mike Doroshenko, Junior Sys Admin
TecKnoQuest Inc.
mi...@tecknoquest.com
www.tecknoquest.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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django performance compared to other web frameworks

2013-08-21 Thread Alex Mandel
On 08/21/2013 10:10 AM, urs.beerli wrote:
> Hi folks!
> 
> I am pretty new to Django and what I have seen so far is very nice, I like 
> it a lot! But one of the most important things to me of a web framework is 
> the performance. If you take a look at:
> http://www.techempower.com/benchmarks/#section=data-r6=i7=update
> Django scores not that good (almost in every test). What are the reasons?
> 
> Thanks
> - Urs
> 

Interesting question. Of course all benchmarks tend to be quite
subjective as to testing strengths vs weakness. Some things I see, for
django they used Postgres but for everything else they used Mysql and
its not clear to me if those DB hits are cold start or not. We also have
no idea if the indexes are the same, what tables types are in use and I
assume the db configuration is stock.

Wsgi they used gunicorn, but we have no idea the configuration of it and
UWSGI is considered much faster than gunicorn (which is actually
considered reasonably faster than apache mod wsgi)

Also you need to compare only frameworks of the same type, Django's
strength is in its completeness, of course some other frameworks will be
faster because they are simpler. Many people consider Rails the biggest
competitor to Django (feature and usage wise), if you limit your
comparison to that Django looks quite good.

The reality is you need to make a django app for yourself and see if it
handles the load you want it to handle fast enough for you. At that
point then look for something else. If all your page returns are fast
enough that the user doesn't really notice and it can handle the number
of concurrent users you want, that's all that really matters.

If you really care about it just being as fast as possible, you should
probably be writing it all from scratch or in a minimal framework with
compile optimized code (C++ perhaps).

Enjoy,
Alex

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Django performance compared to other web frameworks

2013-08-21 Thread urs.beerli
Hi folks!

I am pretty new to Django and what I have seen so far is very nice, I like 
it a lot! But one of the most important things to me of a web framework is 
the performance. If you take a look at:
http://www.techempower.com/benchmarks/#section=data-r6=i7=update
Django scores not that good (almost in every test). What are the reasons?

Thanks
- Urs

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Populate choices from model

2013-08-21 Thread Gerd Koetje
im building a prety complicated user detail form with all kinds of fields, 
like:  gender,haircolor,skincolor

some fields have to become dropdowns with only 1 choise out of many
and some fields have to become multiple select fields with alot of choise 
(multiple choises allowed)
I was trying to use 1 model that holds all the values for each field, but 
it seem to only work if i make a model for each field values

the dropdowns seem to work ok with foreignkey

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Populate choices from model

2013-08-21 Thread C. Kirby
Why are you trying to link to another model with a CharField and not a 
ForeignKey? You seem to be trying to do something that is almost certainly 
not the way is should be done. Perhaps you should explain what you are 
trying to accomplish.

On Wednesday, August 21, 2013 10:44:55 AM UTC-5, Gerd Koetje wrote:
>
> regio = models.CharField(max_length=100, choices=Regio, default=
> 'Amsterdam')
>
> land = models.CharField(max_length=100, choices=Landen, default=
> 'Nederland')
>
> (django-env)[root@python pythondating]# python manage.py syncdb
> CommandError: One or more models did not validate:
> profielen.profielen: "regio": "choices" should be iterable (e.g., a tuple 
> or list).
> profielen.profielen: "land": "choices" should be iterable (e.g., a tuple 
> or list).
>
>
> it doesnt seem to accept a object
>
>
>
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Periodic tasks

2013-08-21 Thread Some Developer

On 20/08/13 21:36, Arnold Krille wrote:

On Sat, 17 Aug 2013 03:36:29 +0100 Some Developer
 wrote:

I'm aware of django-cron and django-celery, both of which are capable
of doing what I want but I was wondering if I was just making a
fundamental design mistake and there maybe a better option that
someone here could explain.

Basically customers pay money into their account in advance so that
they can use services that we offer. Each service is charged by the
minute and prices between services can vary wildly. I need to be able
to show our clients their current running total to the nearest hour
so that they know when they need to add extra funds to their account.

My initial thought was that I would just have the equivalent of a
cron job running every hour that queries the database for the state
of each users application and then used that to produce an estimate
for their current billing.

Alternately I could get rid of the hourly period task and just work
it out when a customer visits a certain page but that is likely to
lead to long load times and heavy database use.

Any suggestions on what you would do in this situation?


Calculate the value on each visit for now.
Worry about the execution-time when your database actually has lots of
users, payments and service-charges applied and the site does get slow
to load. Then use django-debug-toolbar to see how many queries your are
running to calculate the number and how long these queries take. Try to
reduce the number of queries, do whatever you can in the database
instead of in python.
When you have reached your end of wisdom while optimizing the
algorithm and the sql (or djangos use of sql through the orm), start
looking into celery/cron/django-extensions. While celery _can_ do
regular jobs, its not really its primary use. And probably not worth
setting up celery+redis when you only want it to do cron-jobs. If you
need celery for other stuff already, then use it for cron-jobs too. But
otherwise its probably better to look at the cronjobs-framework of
django-extensions.


Thanks.

I think that is what I will do in the short term to ensure that the 
correct data is generated. I'm just not entirely sure how fast this 
project will grow so I'll need a longer term plan in place as well 
in-case the system is unacceptably slow for users.


--
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: ManyToManyField select only results that match

2013-08-21 Thread Tom Lockhart

On 2013-08-21, at 7:25 AM, Gerd Koetje  wrote:

> He Thomas, ur right i didnt explain myself very well.
> 
> 
> What im trying todo is this.
> 
> I have a mode that holds all my form field values in difrant group , name: 
> Keuzes  
> Now i want to populate multiple form fields with these values based on wich 
> groep i want them to be.
> I onloy seem to get this to work if i make a difrant model for each field, 
> cant i just use 1 model with a group field and select the value bases on the 
> group i ask for?
> 
> I think im still a bit confused what i should do i models and what i should 
> do in forms.
> 

Models set up the relationships and forms pull those together for presentation 
or manipulation. I think ;)

So now I'm not sure what you are asking for. Perhaps I could understand from 
the names you have chosen for fields and models, but I am still uncertain.

So you have a set of possible field values, and want to be able to group those 
into different sets for a form, right?

class FieldValues(models.Model):
  name = CharField()
  pass

class FieldGroups(models.Model):
  group_name = CharField()
  values = ManyToManyField(FieldValues, related_name="groups")
  pass

Unless I've got myself turned around, I think you can access fields from the 
groups model and groups from the fields model. Something like

MyGroups = FieldGroups.objects.all()
MyFields = FieldValues.objects.filter(groups__group_name="the group I want")

hth

  - Tom

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I create a script to fill in django admin login form and submit?

2013-08-21 Thread 7equivalents
Thankyou Wongo Bongo! Your solution was spot on correct. It came down to 
one line of code that I modified that was the problem.

login_data = {'username':'jim', 'password':'beam', 
'this_is_the_login_form':'1', 'csrfmiddlewaretoken':csrftoken}

You gave me the correct line, however the, 'this_is_the_login_form':'1' I 
thought you were giving me a generic form name to be replaced with my form 
name, however 'this_is_the_login_form' is the correct form name.

This is where my inexperince has shown through. How did you know that that 
was the name of the form? When I went to django.contrib.auth.forms, it 
seemed the form name was AuthenticationForm, and when I used view source in 
a browser it looked like the form was named login-form. How could one know 
the form was named 'this_is_the_login_form'?



On Monday, August 19, 2013 12:13:21 AM UTC-4, WongoBongo wrote:
>
> You were missing a key. The following works on my machine.
>
> K
>
> ---
>
>
> import requests
> login_url = "http://192.168.0.21/admin/login/;
>
>
> client = requests.session()
> client.get(login_url)
>
>
> csrftoken = client.cookies['csrftoken']
>
>
> login_data = {'username':'jim', 'password':'beam', 
> 'this_is_the_login_form':'1', 'csrfmiddlewaretoken':csrftoken}
>
>
> r = client.post(login_url, data=login_data)
>
>
> target_url = "http://192.168.0.21/admin/auth/user/;
> t = client.get(target_url)
>
>
> 'Select user to change' in t.text # True 
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Populate choices from model

2013-08-21 Thread Gerd Koetje
 

regio = models.CharField(max_length=100, choices=Regio, default=
'Amsterdam')

land = models.CharField(max_length=100, choices=Landen, default=
'Nederland')

(django-env)[root@python pythondating]# python manage.py syncdb
CommandError: One or more models did not validate:
profielen.profielen: "regio": "choices" should be iterable (e.g., a tuple 
or list).
profielen.profielen: "land": "choices" should be iterable (e.g., a tuple or 
list).


it doesnt seem to accept a object




-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Populate choices from model

2013-08-21 Thread C. Kirby
If you want your field to represent another model you should be using a 
foreign key, not a CharField

regio = models.ForeignKey(Regio, default = Regio.objects.get(name = 
"Amsterdam"))

On Wednesday, August 21, 2013 10:24:11 AM UTC-5, Gerd Koetje wrote:
>
> Hi all,
>
> How do i populate choices from a model class inside models.py
>
> doenst work:
>
> regio = models.CharField(max_length=100, choices=list(Regio), default=
> 'Amsterdam')
> regio = models.CharField(max_length=100, choices=Regio, default=
> 'Amsterdam')
>
>
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Populate choices from model

2013-08-21 Thread Rafael E. Ferrero
look here
https://docs.djangoproject.com/en/1.5/ref/models/fields/#django.db.models.Field.choices

"... note that choices can be any iterable object – not necessarily a list
or tuple. This lets you construct choices dynamically. But if you find
yourself hacking
choicesto
be dynamic, you’re probably better off using a proper database table
with a 
ForeignKey.
choicesis
meant for static data that doesn’t change much, if ever. "

See ya!


2013/8/21 Gerd Koetje 

> Hi all,
>
> How do i populate choices from a model class inside models.py
>
> doenst work:
>
> regio = models.CharField(max_length=100, choices=list(Regio), default=
> 'Amsterdam')
> regio = models.CharField(max_length=100, choices=Regio, default=
> 'Amsterdam')
>
>
>
>  --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Rafael E. Ferrero
Claro: (03562) 15514856

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django 1.5 Tutorial Part 3, Test after Update of Polls/urls.py

2013-08-21 Thread Diek Kearney
And I forgot to say thanks, I appreciate the help and guidance.

derrick

On Wednesday, August 21, 2013 10:23:12 AM UTC-3, Mauro Rocco wrote:
>
> Hi,
> The 34 is the id of the pool record in the database. This means that you 
> don't have a pool with that ID in the database.
> If you already created some pool object you will probably see something if 
> you navigate to this url /polls/1/results/.
> If also in this case you got 404 make sure you actually have some pool 
> object in the db.
>
> Regards
>
> On Wednesday, August 21, 2013 6:02:16 AM UTC+2, Diek Kearney wrote:
>>
>> I am going through the Tutorial Django 1.5 Tutorial Part 3, and up to the 
>> current point everything was running smoothly, then I hit a wall that I 
>> cannot figure out. Maybe I am too focused on following, anyways I need some 
>> help.
>>
>> After I updated Polls/urls.py:
>>
>> from django.conf.urls import patterns, include, url
>>
>>
>> from polls import views
>>
>>
>> urlpatterns = patterns('',
>>
>># ex: /polls/
>>
>>url(r'^$', views.index, name='index'),
>>
>># ex: /polls/5/
>>
>>url(r'^(?P\d+)/$',
>>
>>views.detail, name='detail'),
>>
>># ex: /polls/5/results/
>>
>>url(r'^(?P\d+)/results/$',
>>
>>views.results, name='results'),
>>
>># ex: /polls/5/vote/
>>
>>url(r'^(?P\d+)/vote/$',
>>
>>views.vote, name='vote'),
>>
>>)
>>
>> The next step is "Take a look in your browser, at “/polls/34/”. It’ll 
>> run the detail() method and display whatever ID you provide in the URL. 
>> Try “/polls/34/results/” and “/polls/34/vote/” too – these will display the 
>> placeholder results and voting pages." I tried and nothing. It generates 
>> a 404 error. Where exactly is the 34 coming from? I like to think things 
>> through but as a beginner in django following a tutorial I need more when 
>> it comes to this section.
>>
>> Thanks,
>>
>> Derrick
>>  
>>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django 1.5 Tutorial Part 3, Test after Update of Polls/urls.py

2013-08-21 Thread Diek Kearney
Thomas, like I explained to Mauro it was just confusing. Really I should 
have known the problem, I was working on it all last night and I guess I 
needed a break. That said, the tutorial is not clear. In line with the rest 
of the tutorial they should have used 1, vice 34. It works perfect with 1.

Thanks for the help, and that shell trick was quite helpful.

On Wednesday, August 21, 2013 10:50:18 AM UTC-3, Thomas wrote:
>
>
> On 2013-08-20, at 9:02 PM, Diek Kearney  
> wrote:
>
> I am going through the Tutorial Django 1.5 Tutorial Part 3, and up to the 
> current point everything was running smoothly, then I hit a wall that I 
> cannot figure out. Maybe I am too focused on following, anyways I need some 
> help.
> ...
> The next step is "Take a look in your browser, at “/polls/34/”. It’ll run 
> the detail() method and display whatever ID you provide in the URL. Try 
> “/polls/34/results/” and “/polls/34/vote/” too – these will display the 
> placeholder results and voting pages." I tried and nothing. It generates 
> a 404 error. Where exactly is the 34 coming from? I like to think things 
> through but as a beginner in django following a tutorial I need more when 
> it comes to this section.
>
>
>
> Hmm. This *is* confusing since the tutorial should call out the "34" as an 
> example but does not. And at that point in the tutorial it has not given 
> you instruction to enter a particular poll, and not shown you how to get 
> the poll id for any poll you actually did enter.
>
> I was going to suggest that you go to "/polls" to see a list of available 
> polls, but at that point in the tutorial the view for that does not yet 
> exist so no luck there either.
>
> You can try something like:
>
>   python manage.py shell
> from polls.models import Poll
> Poll.objects.all().values()
>
> which will give you a keyword:value list of all fields in your poll model, 
> including the "id" field. That is the value to use in their example query, 
> not the arbitrary "34". Once you have the id (primary key) for a poll, you 
> can try the detailed view which they *have* defined!
>
> You can also look in the database itself for the same info. Try
>
>   python manage.py dbshell
> select * from polls_poll;
>
> hth
>
>   - Tom
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Populate choices from model

2013-08-21 Thread Gerd Koetje
Hi all,

How do i populate choices from a model class inside models.py

doenst work:

regio = models.CharField(max_length=100, choices=list(Regio), default=
'Amsterdam')
regio = models.CharField(max_length=100, choices=Regio, default='Amsterdam')



-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django 1.5 Tutorial Part 3, Test after Update of Polls/urls.py

2013-08-21 Thread Diek Kearney
Mauro,
I kind of thought that may be the case. I guess my main issue it is very 
confusing. Creating views is brand new to me, then the authors tell me to 
do something that  up to that point has not been created. Up to that point 
there is 1 record, where did they come up with 34? And where this tutorial 
has been revised many times I am trusting that it is correct and I should 
follow it to the letter. The tutorial needs to be clarified. And of course 
your recommendation worked.

On Wednesday, August 21, 2013 10:23:12 AM UTC-3, Mauro Rocco wrote:
>
> Hi,
> The 34 is the id of the pool record in the database. This means that you 
> don't have a pool with that ID in the database.
> If you already created some pool object you will probably see something if 
> you navigate to this url /polls/1/results/.
> If also in this case you got 404 make sure you actually have some pool 
> object in the db.
>
> Regards
>
> On Wednesday, August 21, 2013 6:02:16 AM UTC+2, Diek Kearney wrote:
>>
>> I am going through the Tutorial Django 1.5 Tutorial Part 3, and up to the 
>> current point everything was running smoothly, then I hit a wall that I 
>> cannot figure out. Maybe I am too focused on following, anyways I need some 
>> help.
>>
>> After I updated Polls/urls.py:
>>
>> from django.conf.urls import patterns, include, url
>>
>>
>> from polls import views
>>
>>
>> urlpatterns = patterns('',
>>
>># ex: /polls/
>>
>>url(r'^$', views.index, name='index'),
>>
>># ex: /polls/5/
>>
>>url(r'^(?P\d+)/$',
>>
>>views.detail, name='detail'),
>>
>># ex: /polls/5/results/
>>
>>url(r'^(?P\d+)/results/$',
>>
>>views.results, name='results'),
>>
>># ex: /polls/5/vote/
>>
>>url(r'^(?P\d+)/vote/$',
>>
>>views.vote, name='vote'),
>>
>>)
>>
>> The next step is "Take a look in your browser, at “/polls/34/”. It’ll 
>> run the detail() method and display whatever ID you provide in the URL. 
>> Try “/polls/34/results/” and “/polls/34/vote/” too – these will display the 
>> placeholder results and voting pages." I tried and nothing. It generates 
>> a 404 error. Where exactly is the 34 coming from? I like to think things 
>> through but as a beginner in django following a tutorial I need more when 
>> it comes to this section.
>>
>> Thanks,
>>
>> Derrick
>>  
>>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Can I make changes in Django without having to recompile everything?

2013-08-21 Thread Tim Chase
On 2013-08-21 07:21, Johann wrote:
> Please tell me if this is true.  I'm deciding on Django, asp.net,
> or Java.
> 
> If I use asp.net or java and I want to make a change to the
> controller, I have to recompile the class or project, right?

Alas, that's one of the reasons that drove me from Java a while back.

> If I use Django, if I change the controller or model logic, do I
> have to compile everything? 

Effectively, there's no "recompilation" in Python/Django as it's all
handled by Python and fairly transparent to the user.  At worst, you
have to restart the Django process to get Python to do the
recompilation for you.

> If I change a a model, don't I have to use "special" django/py
> commands to fix everything in my ORM?
> If I just make nominal changes to the logic in a controller, I can
> just go with it, no recompile necessary?

If you change the actual database structure (add/remove/rename fields,
change their types, add constraints/indexes, etc) when changing
models, then you'd need to handle those separately.  Best practices
usually suggest using South as the least-painful way to do these
database migrations.  Though often in pre-release code, I'll just
nuke the database and rebuild it from the ground up.

If it's just the logic changing and not the actual database structure,
then Python/Django tends to handle everything for you as mentioned
above (at worst, just restart the process to have Python recompile
your changes).

> Sorry for so many questions.  Thanks.

Anything to save you from ASP/Java development ;-)

-tkc





-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Can I make changes in Django without having to recompile everything?

2013-08-21 Thread Andreas Kuhne
If you compare Django to asp.net or java, django is the easiest to start
things with. You never have to compile anything in django, the server does
it itself. In development mode it will recompile all classes automatically
when you make changes to a file. In a production environment, you may have
to restart the webserver for the compilation to take place.

If you make a change to a model, you do have to run a commandline command
to synchronize the database with your model. However I think it is still
much easier than Java.

Also the learning curve for django is far lower than java.

Regards,

Andréas


2013/8/21 Johann 

> Please tell me if this is true.  I'm deciding on Django, asp.net, or Java.
>
> If I use asp.net or java and I want to make a change to the controller, I
> have to recompile the class or project, right?
>
> If I use Django, if I change the controller or model logic, do I have to
> compile everything?  If I change a a model, don't I have to use "special"
> django/py commands to fix everything in my ORM?  If I just make nominal
> changes to the logic in a controller, I can just go with it, no recompile
> necessary?
>
> Sorry for so many questions.  Thanks.
>
> --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: ManyToManyField select only results that match

2013-08-21 Thread Gerd Koetje
He Thomas, ur right i didnt explain myself very well.


What im trying todo is this.

I have a mode that holds all my form field values in difrant group , name: 
Keuzes  
Now i want to populate multiple form fields with these values based on wich 
groep i want them to be.
I onloy seem to get this to work if i make a difrant model for each field, 
cant i just use 1 model with a group field and select the value bases on 
the group i ask for?

I think im still a bit confused what i should do i models and what i should 
do in forms.





-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Can I make changes in Django without having to recompile everything?

2013-08-21 Thread Johann
Please tell me if this is true.  I'm deciding on Django, asp.net, or Java.

If I use asp.net or java and I want to make a change to the controller, I 
have to recompile the class or project, right?

If I use Django, if I change the controller or model logic, do I have to 
compile everything?  If I change a a model, don't I have to use "special" 
django/py commands to fix everything in my ORM?  If I just make nominal 
changes to the logic in a controller, I can just go with it, no recompile 
necessary?

Sorry for so many questions.  Thanks.

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: ManyToManyField select only results that match

2013-08-21 Thread Tom Lockhart

On 2013-08-21, at 3:46 AM, Gerd Koetje  wrote:

> anyone willing to help out?

I was confused by your original example, talking about a form but then showing 
just one field in a model definition. So I was waiting to learn something from 
a knowledgable response. Instead you are stuck with my guessing ;)

Assuming that those ManyToManyField lines are in a model, here is the problem. 
The related_name argument helps you to access the values in that model from 
Keuzes, using syntax like "keuzes_kleurogen__mykleurogenfield". But the model 
definitions will result in only one intermediate table to mediate the 
many-to-many relationship. You will want two separate intermediate tables for 
that, not one.

Look at the "through" attribute for ManyToManyField and define an extra 
intermediate table for one of those two relationships.

hth

 - Tom

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django 1.5 Tutorial Part 3, Test after Update of Polls/urls.py

2013-08-21 Thread Tom Lockhart

On 2013-08-20, at 9:02 PM, Diek Kearney  wrote:

> I am going through the Tutorial Django 1.5 Tutorial Part 3, and up to the 
> current point everything was running smoothly, then I hit a wall that I 
> cannot figure out. Maybe I am too focused on following, anyways I need some 
> help.
> ...
> The next step is "Take a look in your browser, at “/polls/34/”. It’ll run the 
> detail() method and display whatever ID you provide in the URL. Try 
> “/polls/34/results/” and “/polls/34/vote/” too – these will display the 
> placeholder results and voting pages." I tried and nothing. It generates a 
> 404 error. Where exactly is the 34 coming from? I like to think things 
> through but as a beginner in django following a tutorial I need more when it 
> comes to this section.


Hmm. This *is* confusing since the tutorial should call out the "34" as an 
example but does not. And at that point in the tutorial it has not given you 
instruction to enter a particular poll, and not shown you how to get the poll 
id for any poll you actually did enter.

I was going to suggest that you go to "/polls" to see a list of available 
polls, but at that point in the tutorial the view for that does not yet exist 
so no luck there either.

You can try something like:

  python manage.py shell
from polls.models import Poll
Poll.objects.all().values()

which will give you a keyword:value list of all fields in your poll model, 
including the "id" field. That is the value to use in their example query, not 
the arbitrary "34". Once you have the id (primary key) for a poll, you can try 
the detailed view which they *have* defined!

You can also look in the database itself for the same info. Try

  python manage.py dbshell
select * from polls_poll;

hth

  - Tom

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Problem with translations

2013-08-21 Thread Andreas Kuhne
We are running nginx for static files and apache + mod_wsgi for the django
website.

Regards,

Andréas

2013/8/21 Mauro Rocco 

> Hi,
> That's strange.
> To me looks like the server from time to time can not access this files as
> you said.
> What you use in production Apache/ModWSGI ?
>
> Regards
>
>
> On Wednesday, August 21, 2013 2:57:51 PM UTC+2, Andréas Kühne wrote:
>>
>> Hi,
>>
>> I am working on a website that is available in 10 different languages,
>> and we have the translations working. If you want to see our website in
>> french, you just add /fr to our url and it works fine.
>>
>> However we are getting a lot of :
>>
>>   File "middleware.py", line 83, in process_request
>> translation.activate(request.l**ocale_dict['language'])
>>
>>   File 
>> "env/lib/python2.6/site-**packages/django/utils/**translation/__init__.py",
>> line 90, in activate
>> return _trans.activate(language)
>>
>>   File 
>> "env/lib/python2.6/site-**packages/django/utils/**translation/trans_real.py",
>> line 183, in activate
>> _active.value = translation(language)
>>
>>   File 
>> "env/lib/python2.6/site-**packages/django/utils/**translation/trans_real.py",
>> line 173, in translation
>> current_translation = _fetch(language, fallback=default_translation)
>>
>>   File 
>> "env/lib/python2.6/site-**packages/django/utils/**translation/trans_real.py",
>> line 141, in _fetch
>> res._info = res._info.copy()
>>
>> AttributeError: 'NoneType' object has no attribute '_info'
>>
>> These errors mostly occur when the user requests an ajax enabled update.
>> As far as I can tell this error is related to the fact that django
>> tranlsations can't open the .mo files for the specific locale. What I don't
>> understand is that this happens maybe once every 2 days, so it doesn't
>> happen all the time.
>>
>> The only resources I have found on the subject are regarding to
>> completely missing .mo translation files (which is not the case here). I am
>> leaning towards an issue with apache not being able to open the file,
>> because of restrictions on the number of open files allowed, but I'm not
>> sure. Has anyone any ideas on how to correct this issue? I should also say
>> that it has never happened on our development machines.
>>
>> Regards,
>>
>> Andréas
>>
>  --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Problem with translations

2013-08-21 Thread Mauro Rocco
Hi,
That's strange.
To me looks like the server from time to time can not access this files as 
you said.
What you use in production Apache/ModWSGI ?

Regards

On Wednesday, August 21, 2013 2:57:51 PM UTC+2, Andréas Kühne wrote:
>
> Hi,
>
> I am working on a website that is available in 10 different languages, and 
> we have the translations working. If you want to see our website in french, 
> you just add /fr to our url and it works fine.
>
> However we are getting a lot of :
>
>   File "middleware.py", line 83, in process_request
> translation.activate(request.locale_dict['language'])
>
>   File 
> "env/lib/python2.6/site-packages/django/utils/translation/__init__.py", 
> line 90, in activate
> return _trans.activate(language)
>
>   File 
> "env/lib/python2.6/site-packages/django/utils/translation/trans_real.py", 
> line 183, in activate
> _active.value = translation(language)
>
>   File 
> "env/lib/python2.6/site-packages/django/utils/translation/trans_real.py", 
> line 173, in translation
> current_translation = _fetch(language, fallback=default_translation)
>
>   File 
> "env/lib/python2.6/site-packages/django/utils/translation/trans_real.py", 
> line 141, in _fetch
> res._info = res._info.copy()
>
> AttributeError: 'NoneType' object has no attribute '_info'
>
> These errors mostly occur when the user requests an ajax enabled update. 
> As far as I can tell this error is related to the fact that django 
> tranlsations can't open the .mo files for the specific locale. What I don't 
> understand is that this happens maybe once every 2 days, so it doesn't 
> happen all the time. 
>
> The only resources I have found on the subject are regarding to completely 
> missing .mo translation files (which is not the case here). I am leaning 
> towards an issue with apache not being able to open the file, because of 
> restrictions on the number of open files allowed, but I'm not sure. Has 
> anyone any ideas on how to correct this issue? I should also say that it 
> has never happened on our development machines. 
>
> Regards, 
>
> Andréas
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django 1.5 Tutorial Part 3, Test after Update of Polls/urls.py

2013-08-21 Thread Mauro Rocco
Hi,
The 34 is the id of the pool record in the database. This means that you 
don't have a pool with that ID in the database.
If you already created some pool object you will probably see something if 
you navigate to this url /polls/1/results/.
If also in this case you got 404 make sure you actually have some pool 
object in the db.

Regards

On Wednesday, August 21, 2013 6:02:16 AM UTC+2, Diek Kearney wrote:
>
> I am going through the Tutorial Django 1.5 Tutorial Part 3, and up to the 
> current point everything was running smoothly, then I hit a wall that I 
> cannot figure out. Maybe I am too focused on following, anyways I need some 
> help.
>
> After I updated Polls/urls.py:
>
> from django.conf.urls import patterns, include, url
>
>
> from polls import views
>
>
> urlpatterns = patterns('',
>
># ex: /polls/
>
>url(r'^$', views.index, name='index'),
>
># ex: /polls/5/
>
>url(r'^(?P\d+)/$',
>
>views.detail, name='detail'),
>
># ex: /polls/5/results/
>
>url(r'^(?P\d+)/results/$',
>
>views.results, name='results'),
>
># ex: /polls/5/vote/
>
>url(r'^(?P\d+)/vote/$',
>
>views.vote, name='vote'),
>
>)
>
> The next step is "Take a look in your browser, at “/polls/34/”. It’ll run 
> the detail() method and display whatever ID you provide in the URL. Try 
> “/polls/34/results/” and “/polls/34/vote/” too – these will display the 
> placeholder results and voting pages." I tried and nothing. It generates 
> a 404 error. Where exactly is the 34 coming from? I like to think things 
> through but as a beginner in django following a tutorial I need more when 
> it comes to this section.
>
> Thanks,
>
> Derrick
>  
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I create a script to fill in django admin login form and submit?

2013-08-21 Thread 7equivalents
Still trying to solve this. I cant seem to find anything by googling.

I did read this. 
https://docs.djangoproject.com/en/dev/topics/auth/default/#django.contrib.auth.login

However, when I'm doing this from the shell, I'm not sure what to use as 
request in the Login(request,user) function.

Also when I look at the contrib.auth forms. it appears the form is name 
AuthenticationForm. But when I open the actual admin login page with my 
browser and view source it appears to be called login-form.

I would thing trying to login as a user from the shell would be a common 
occurrence, but I cant figure out how.




-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Problem with translations

2013-08-21 Thread Andreas Kuhne
Hi,

I am working on a website that is available in 10 different languages, and
we have the translations working. If you want to see our website in french,
you just add /fr to our url and it works fine.

However we are getting a lot of :

  File "middleware.py", line 83, in process_request
translation.activate(request.locale_dict['language'])

  File "env/lib/python2.6/site-packages/django/utils/translation/__init__.py",
line 90, in activate
return _trans.activate(language)

  File "env/lib/python2.6/site-packages/django/utils/translation/trans_real.py",
line 183, in activate
_active.value = translation(language)

  File "env/lib/python2.6/site-packages/django/utils/translation/trans_real.py",
line 173, in translation
current_translation = _fetch(language, fallback=default_translation)

  File "env/lib/python2.6/site-packages/django/utils/translation/trans_real.py",
line 141, in _fetch
res._info = res._info.copy()

AttributeError: 'NoneType' object has no attribute '_info'

These errors mostly occur when the user requests an ajax enabled update. As
far as I can tell this error is related to the fact that django
tranlsations can't open the .mo files for the specific locale. What I don't
understand is that this happens maybe once every 2 days, so it doesn't
happen all the time.

The only resources I have found on the subject are regarding to completely
missing .mo translation files (which is not the case here). I am leaning
towards an issue with apache not being able to open the file, because of
restrictions on the number of open files allowed, but I'm not sure. Has
anyone any ideas on how to correct this issue? I should also say that it
has never happened on our development machines.

Regards,

Andréas

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


How to sync database and/or discard/disable cache?

2013-08-21 Thread Dig
Hi,

  I'm going to deploy my Django application to Amazon Web Service (AWS), 
and found some strange with AWS RDS (Relational Database Service, I choose 
MySQL 5.5 with InnoDB Engine).

My application is running in Django 1.5, and Python 2.6,

I found following behavior:
Case A:
  Request 1: Delete record A in database, and query record A (it does not 
exist)
  Request 2: Query record A, (it does not exist), and insert record B
*  Request 3: Query record A, (it EXISTS), Query record B, (it does not 
exist),*
  Request 4: Query record A, (it does not exist), Query record B, (it 
exists),

Case B:
  Request 1: Delete record A, and query record A, (it does not exist),
*  Request 2: Query record A, (it EXISTS)*
  Request 3: Query record A, (it does not exist)



These 2 situation not 100% happened (but > 30%), I guess it caused some 
cache (django cache or mysql cache).
Can anyone tell me how to disable Django cache?

Thank you.

Regards,
Dig

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Django 1.5 Tutorial Part 3, Test after Update of Polls/urls.py

2013-08-21 Thread Diek Kearney
I am going through the Tutorial Django 1.5 Tutorial Part 3, and up to the 
current point everything was running smoothly, then I hit a wall that I 
cannot figure out. Maybe I am too focused on following, anyways I need some 
help.

After I updated Polls/urls.py:

from django.conf.urls import patterns, include, url


from polls import views


urlpatterns = patterns('',

   # ex: /polls/

   url(r'^$', views.index, name='index'),

   # ex: /polls/5/

   url(r'^(?P\d+)/$',

   views.detail, name='detail'),

   # ex: /polls/5/results/

   url(r'^(?P\d+)/results/$',

   views.results, name='results'),

   # ex: /polls/5/vote/

   url(r'^(?P\d+)/vote/$',

   views.vote, name='vote'),

   )

The next step is "Take a look in your browser, at “/polls/34/”. It’ll run 
the detail() method and display whatever ID you provide in the URL. Try 
“/polls/34/results/” and “/polls/34/vote/” too – these will display the 
placeholder results and voting pages." I tried and nothing. It generates a 
404 error. Where exactly is the 34 coming from? I like to think things 
through but as a beginner in django following a tutorial I need more when 
it comes to this section.

Thanks,

Derrick
 

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Django error with installing reviewboard on solaris.

2013-08-21 Thread tomoya . fujita825
I'm trying to install reviewboard on solaris 10, but this Django problem 
stops me to do that.
Does anyone know how to get through this problem?
(python is 2.4)

bash-3.2# pwd

/home/fujita/Downloads/Django-1.3.7

bash-3.2# python setup.py install

... snip

 

bash-3.2# ls -lt /usr/lib/python2.4/site-packages/

total 2417

...snip

drwxr-xr-x  17 root root  19 Aug 21 17:14 django-> 
/* django is installed. */

drwxr-xr-x   5 root root   5 Aug 21 16:53 
ReviewBoard-1.5.7-py2.4.egg

drwxr-xr-x   5 root root   5 Aug 21 16:41 
Djblets-0.6.10-py2.4.egg

drwxr-xr-x   5 root root   5 Aug 19 23:18 
django_evolution-0.6.5-py2.4.egg

drwxr-xr-x   4 root root   4 Aug 19 23:16 Pygments-1.4-py2.4.egg

-rw-r--r--   1 root root  30 Aug 19 16:47 setuptools.pth

-rw-r--r--   1 root root 546 Aug 19 16:09 easy-install.pth

drwxr-xr-x   4 root root  10 Aug 19 15:41 
PIL-1.1.6-py2.4-solaris-2.10-sun4u.egg

-rw-r--r--   1 root root  136261 Aug 19 15:34 flup-1.0-py2.4.egg

-rw-r--r--   1 root root  308077 Aug 19 15:18 
paramiko-1.11.0-py2.4.egg

drwxr-xr-x   4 root root   4 Aug 19 14:38 
python_dateutil-1.5-py2.4.egg

drwxr-xr-x   3 root root   5 Aug 19 14:27 
python_memcached-1.53-py2.4.egg

drwxr-xr-x   4 root root  10 Aug  8 22:00 
setuptools-0.6c11-py2.4.egg

drwxr-xr-x   7 root root  29 Aug 22  2011 docutils

-rw-r--r--   1 root root3365 Aug 22  2011 roman.pyc

-rw-r--r--   1 root root  514206 May  8  2011 pytz-2011g-py2.4.egg

-rw-r--r--   1 root root7419 Jun 21  2007 
recaptcha_client-1.0.1-py2.4.egg

...snip

 

bash-3.2# cat /usr/lib/python2.4/site-packages/easy-install.pth

import sys; sys.__plen = len(sys.path)

./setuptools-0.6c11-py2.4.egg

./ReviewBoard-1.5.7-py2.4.egg

./recaptcha_client-1.0.1-py2.4.egg

./pytz-2011g-py2.4.egg

./python_memcached-1.53-py2.4.egg

./python_dateutil-1.5-py2.4.egg

./paramiko-1.11.0-py2.4.egg

./flup-1.0-py2.4.egg

./Pygments-1.4-py2.4.egg

./PIL-1.1.6-py2.4-solaris-2.10-sun4u.egg

./Djblets-0.6.10-py2.4.egg

./django_evolution-0.6.5-py2.4.egg

import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; 
p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = 
p+len(new)

 

bash-3.2# easy_install ReviewBoard-1.5.7-py2.4.egg

Processing ReviewBoard-1.5.7-py2.4.egg

removing '/usr/lib/python2.4/site-packages/ReviewBoard-1.5.7-py2.4.egg' 
(and everything under it)

creating /usr/lib/python2.4/site-packages/ReviewBoard-1.5.7-py2.4.egg

Extracting ReviewBoard-1.5.7-py2.4.egg to /usr/lib/python2.4/site-packages

ReviewBoard 1.5.7 is already the active version in easy-install.pth

Installing rb-site script to /usr/bin

Installing rbssh script to /usr/bin

 

Installed /usr/lib/python2.4/site-packages/ReviewBoard-1.5.7-py2.4.egg

Processing dependencies for ReviewBoard==1.5.7

Searching for Django>=1.1.3

Reading http://downloads.reviewboard.org/mirror/

Reading http://downloads.reviewboard.org/releases/ReviewBoard/1.5/

Reading http://pypi.python.org/simple/Django/

No local packages or download links found for Django>=1.1.3

Best match: None

Traceback (most recent call last):

  File "/usr/bin/easy_install", line 7, in ?

sys.exit(

  File 
"/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/command/easy_install.py",
 
line 1712, in main

with_ei_usage(lambda:

  File 
"/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/command/easy_install.py",
 
line 1700, in with_ei_usage

return f()

  File 
"/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/command/easy_install.py",
 
line 1716, in 

distclass=DistributionWithoutHelpCommands, **kw

  File "/usr/lib/python2.4/distutils/core.py", line 149, in setup

dist.run_commands()

  File "/usr/lib/python2.4/distutils/dist.py", line 946, in run_commands

self.run_command(cmd)

  File "/usr/lib/python2.4/distutils/dist.py", line 966, in run_command

cmd_obj.run()

  File 
"/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/command/easy_install.py",
 
line 211, in run

self.easy_install(spec, not self.no_deps)

  File 
"/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/command/easy_install.py",
 
line 427, in easy_install

return self.install_item(None, spec, tmpdir, deps, True)

  File 
"/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/command/easy_install.py",
 
line 478, in install_item

self.process_distribution(spec, dist, deps)

  File 
"/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/setuptools/command/easy_install.py",
 
line 518, in process_distribution

distros = WorkingSet([]).resolve(

  File 
"/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg/pkg_resources.py",
 
line 563, in resolve

dist = best[req.key] = 

Re: ManyToManyField select only results that match

2013-08-21 Thread Gerd Koetje
anyone willing to help 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to edit many-to-many relationships with data from custom intermediary table?

2013-08-21 Thread DJ-Tom


I'm not sure what the easiest way would be to make the Quantity field 
> editable - I thought about a* fieldset *but how do I get the data from 
> the intermediary table into that???
>
>
ooops - I meant FORMset, not fieldset... (why is there no way to edit my 
own post?) 

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


How to edit many-to-many relationships with data from custom intermediary table?

2013-08-21 Thread DJ-Tom
Hi,

I'm currently working on a room management application for events.

One part of it is a list of room setups with associated equipment, each 
room can have an arbitrary number of  different equipment (such as screens, 
IT-equipment, A/, tables etc.)

Each equipment also has an attribute "number/quantity" to define how many 
of it is needed, so I created a custom intermediary table (instead of 
relying on the built-in one):

class roomsetup(models.Model):
name = models.CharField("Name", max_length=60)
equipments = models.ManyToManyField(equipment, 
through='roomsetup_equipments')  # use custom intermediary  table

class equipment(models.Model):
name = models.CharField("Name", max_length=60)

# custom intermediary m2m table...
class roomsetup_equipments(models.Model):
roomsetup = models.ForeignKey(roomsetup)
equipment = models.ForeignKey(equipment)
number = models.DecimalField('Quantity/number', max_digits=6, 
decimal_places=2, blank=True, null=False, default=1)

The "standard" roomsetup form I created just displays a plain list of 
equipment, there is no way to change the quantity:

class RoomsetupForm(ModelForm):
class Meta:
model = roomsetup
fields = ('active', 'name', 'roomlayout', 'equipments', 'notes',)

I'm not sure what the easiest way would be to make the Quantity field 
editable - I thought about a fieldset but how do I get the data from the 
intermediary table into that???

Any hint/sample would be appreciated.

thomas

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: online Django users directory ?

2013-08-21 Thread Fabrice Romand
perfect


2013/8/21 Russell Keith-Magee 

> Hi Fabrice:
>
> Sounds like you're looking for:
>
> https://people.djangoproject.com
>
> Yours,
> Russ Magee %-)
>
>
> On Wed, Aug 21, 2013 at 5:03 AM, Fabrice Romand 
> wrote:
>
>> Hi,
>>
>> Do you know any online Django users directory ?
>>
>> if not, will you support a such project ?
>>
>>
>>  --
>> 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.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/5wYQ7UOobrM/unsubscribe.
> To unsubscribe from this group and all its topics, 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 

Cordialement,

Fabrice Romand
mobile: +33 628188143
MeetMe: http://doodle.com/fabrom

Le 15 mai 2014, le domaine jability.org expirera. Merci de ne plus m'écrire
à l'adresse fab...@jability.org

Merci de ne pas m'envoyer de documents dans des formats fermés tels que MS
Word, Excel ou
PowerPoint, ...). Pour les documents "à lire", préférez les diffuser dans
des formats ouverts 
(texte brut, pdf, html, ...) afin de les rendre accessibles au plus grand
nombre et sur un plus large
éventail de périphériques.

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


[no subject]

2013-08-21 Thread Shahmi Junoh
Hi,

I would like to unsubscribe from getting the updates.

Thanks in advance.

Regards,
Shahmi

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: online Django users directory ?

2013-08-21 Thread Russell Keith-Magee
Hi Fabrice:

Sounds like you're looking for:

https://people.djangoproject.com

Yours,
Russ Magee %-)


On Wed, Aug 21, 2013 at 5:03 AM, Fabrice Romand wrote:

> Hi,
>
> Do you know any online Django users directory ?
>
> if not, will you support a such project ?
>
>
>  --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Any Django users in Reims (France) ?

2013-08-21 Thread anthony tresontani

Salut,

Je suis sur Metz mais ca peut m'intéressé :)

Anthony

Le 21/08/2013 08:28, Fabrice Romand a écrit :

Bonjour,
Je cherche des dev Django dans la région de Reims (France)
pour organiser des rencontres sympas et échanger sur notre plateforme 
préférée

voire développer ensemble nos excellentes idées.
A votre écoute,
Fabrice
--
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.
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Using django.contrib.auth...

2013-08-21 Thread Nigel Legg
Thanks very much Laurent, I will have a go with that this morning. 
Regards, N/ 

On Monday, 19 August 2013 16:25:00 UTC+1, Laurent Meunier wrote:
>
> On 19/08/2013 17:05, Nigel Legg wrote: 
> > In the app I am building for data analysis, I want all logged in users 
> > to be able to access all parts of the system, but only to have access to 
> > the datafiles they hae uploaded themselves.  Can I use 
> > django.contrib.auth to filter the full list of datafiles according to 
> > the user object? 
> > If so, how do I go about this? I'm thinking of attaching a user_id field 
> > to the file when it is uploaded, and then filtering against that wen a 
> > logged in user goes to the list of files, but I'm not sure how I would 
> > implement this. 
> > Any help greatly appreciated. 
>
> Hi, 
>
> Your best option is to add a foreign key to your user model (usually 
> django.contrib.auth.models.User) in your model that handles your 
> datafiles. 
>
> from django.contrib.auth.models import User 
>
> class Datafile(models.Model): 
>  user = models.ForeignKey(User) 
>  ... 
>
>
> When a user upload a datafile, don't forget to set the user field: 
>
> mydatafile.user = request.user 
>
>
> And then you can filter datafiles: 
>
> Datafile.objects.filter(user=request.user) 
>
>
> -- 
> Laurent Meunier  
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Any Django users in Reims (France) ?

2013-08-21 Thread Fabrice Romand
Bonjour,
Je cherche des dev Django dans la région de Reims (France) 
pour organiser des rencontres sympas et échanger sur notre plateforme 
préférée
voire développer ensemble nos excellentes idées.
A votre écoute,
Fabrice

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: online Django users directory ?

2013-08-21 Thread Fabrice Romand
mainely finding people who offering/searching django skill for local job, 
help, exchange
others ideas ?

Le mercredi 21 août 2013 07:31:37 UTC+2, אברהם סרור a écrit :
>
> What for?
> On Aug 21, 2013 12:04 AM, "Fabrice Romand" 
>  
> wrote:
>
>> Hi,
>>
>> Do you know any online Django users directory ?
>>
>> if not, will you support a such project ?
>>
>>
>>  -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> 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.
For more options, visit https://groups.google.com/groups/opt_out.