Force exception raising when transaction fails

2012-11-20 Thread Isaac XXX

Hi everybody,

I run into a weird scenario, caused by a complex code involving threads 
and so on.


The problem arised in some point, with a DatabaseError exception, saying:

/current transaction is aborted, commands ignored until end of 
transaction block/


Obviously, the line which arises that error is the next one after 
transaction is corrupted. So, my question is: how do I can force django 
to raise exceptions when a given transaction fail?


An example is the following

func1()
func2() <-- Here, a db transaction fails, making all next calls raise 
that DatabaseError exception

func3() <-- Here DatabaseError is raised

I just want that func2 notice me that there is an error with its 
transaction.


Thank you in advance

Vyrphan


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: how to use get_queryset in my code

2012-11-20 Thread Daniel Roseman
On Tuesday, 20 November 2012 07:25:55 UTC, Nebros wrote:

> I can really need your help, i don't have found the solution till now. :( 
>

You've had no replies because no-one can understand what you're asking. 
Something about querysets, but you seem to be using raw SQL in your 
code, for no apparent reason. And your code is totally unclear: what is 
that nested function doing, and why does it refer to `self`? And why is it 
calling itself?

Please post a *minimal* example that shows the problem, and describe 
exactly what you want to achieve and exactly what is going wrong, including 
any errors you receive.
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/YSQpvIO-zDwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to syncdb programatically (django standalone script) ?

2012-11-20 Thread Samar Agrawal
Wow this is the coolest thing...thnx

On Tuesday, 16 September 2008 07:20:24 UTC+5:30, Steve Holden wrote:
>
> Mathieu Leplatre wrote:
> > Hi all,
> >
> > I found many post about specific errors regarding django as a
> > standalone tool.
> >
> > With a little bit of researching, I ended up with this script below.
> > Unfortunately, it fails on database initialization.
> >
> > ...
> > ...
> >  File "/home/mathieu/Code/uhm/svn/uhm/django/db/backends/sqlite3/
> > base.py", line 167, in execute
> >return Database.Cursor.execute(self, query, params)
> >sqlite3.OperationalError: no such table: polls_poll
> >
> > The sqlite file is empty (0 byte). How can I syncdb programatically
> > (and only once) ?
> >
> > Thanks !
> >
> >
> > import datetime
> > from django.conf import settings
> > settings.configure( DATABASE_ENGINE = "sqlite3",
> > DATABASE_NAME   = "./polls.db",
> > INSTALLED_APPS = ('polls'))
> > from django.db import models
> >
> > class Poll(models.Model):
> > question = models.CharField(max_length=200)
> > pub_date = models.DateTimeField('date published')
> > class Meta:
> > app_label = "polls"
> >
> > p = Poll(question="What's up?", pub_date=datetime.datetime.now())
> > p.save()
> >   
> This is k=nd of a wild-assed guess. Please tell me if it works.
>
> from django.core.management import call_command
> call_command('syncdb')
>
> regards
>  Steve
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/DNWaqBp35PsJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



missing column name in subclasses

2012-11-20 Thread Emmanuel Jannetti
Hi,

Using django 1.3.1 with SQLlight backend. 
I want to use the following kind of model.


*class Bar(models.Model):
  a = models.PositiveSmallIntegerField(default=1)

class Foo(models.Model):
   mybar = 
models.ForeignKey(Bar,blank=False,null=True,on_delete=models.CASCADE)
   class Meta:
  abstract = True

class Sub(Foo):
  b = models.PositiveSmallIntegerField(default=1)

class SubFoo(Foo):
  c = models.PositiveSmallIntegerField(default=1)*


The model seems fine and validate correctly . corresponding created SQL is 



*CREATE TABLE "devLab_bar" (*
*"id" integer NOT NULL PRIMARY KEY,*
*"a" smallint unsigned NOT NULL*
*)*
*;*
*CREATE TABLE "devLab_sub" (*
*"id" integer NOT NULL PRIMARY KEY,*
*"mybar_id" integer REFERENCES "devLab_bar" ("id"),*
*"b" smallint unsigned NOT NULL*
*)*
*;*
*CREATE TABLE "devLab_subfoo" (*
*"id" integer NOT NULL PRIMARY KEY,*
*"mybar_id" integer REFERENCES "devLab_bar" ("id"),*
*"c" smallint unsigned NOT NULL*
*)*



When I try to create an 'SubFoo' item , I got an error about missing field.

*python manage.py shell*
*Python 2.7.3 (default, Sep 26 2012, 21:51:14) *
*[GCC 4.7.2] on linux2*
*Type "help", "copyright", "credits" or "license" for more information.*
*(InteractiveConsole)*
*>>> from devLab.models import Sub,SubFoo*
*>>> Sub().save()*
*>>> SubFoo().save()*
*Traceback (most recent call last):*
*  File "", line 1, in *
*  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", 
line 460, in save*
*self.save_base(using=using, force_insert=force_insert, 
force_update=force_update)*
*  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", 
line 553, in save_base*
*result = manager._insert(values, return_id=update_pk, using=using)*
*  File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 
195, in _insert*
*return insert_query(self.model, values, **kwargs)*
*  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", 
line 1436, in insert_query*
*return query.get_compiler(using=using).execute_sql(return_id)*
*  File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", 
line 791, in execute_sql*
*cursor = super(SQLInsertCompiler, self).execute_sql(None)*
*  File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", 
line 735, in execute_sql*
*cursor.execute(sql, params)*
*  File 
"/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 
34, in execute*
*return self.cursor.execute(sql, params)*
*  File 
"/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py", 
line 234, in execute*
*return Database.Cursor.execute(self, query, params)*
*DatabaseError: table devLab_subfoo has no column named mybar_id*
*>>>* 


I cannot figure out why I get this error.
thank in advance for any help.







-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/7VJOij2CFh0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Multi Database + Huge lookups

2012-11-20 Thread alexandre...@gmail.com
Thanks

I will follow directions

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/UzXu0Wzm4W0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: missing column name in subclasses

2012-11-20 Thread Tom Evans
On Tue, Nov 20, 2012 at 10:23 AM, Emmanuel Jannetti
 wrote:
> Hi,
>
> Using django 1.3.1 with SQLlight backend.
> I want to use the following kind of model.
>
>
> class Bar(models.Model):
>   a = models.PositiveSmallIntegerField(default=1)
>
> class Foo(models.Model):
>mybar =
> models.ForeignKey(Bar,blank=False,null=True,on_delete=models.CASCADE)
>class Meta:
>   abstract = True
>
> class Sub(Foo):
>   b = models.PositiveSmallIntegerField(default=1)
>
> class SubFoo(Foo):
>   c = models.PositiveSmallIntegerField(default=1)
>
>
> The model seems fine and validate correctly . corresponding created SQL is
>
>
>
> CREATE TABLE "devLab_bar" (
> "id" integer NOT NULL PRIMARY KEY,
> "a" smallint unsigned NOT NULL
> )
> ;
> CREATE TABLE "devLab_sub" (
> "id" integer NOT NULL PRIMARY KEY,
> "mybar_id" integer REFERENCES "devLab_bar" ("id"),
> "b" smallint unsigned NOT NULL
> )
> ;
> CREATE TABLE "devLab_subfoo" (
> "id" integer NOT NULL PRIMARY KEY,
> "mybar_id" integer REFERENCES "devLab_bar" ("id"),
> "c" smallint unsigned NOT NULL
> )
>
>
>
> When I try to create an 'SubFoo' item , I got an error about missing field.
>
> python manage.py shell
> Python 2.7.3 (default, Sep 26 2012, 21:51:14)
> [GCC 4.7.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
 from devLab.models import Sub,SubFoo
 Sub().save()
 SubFoo().save()
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py",
> line 460, in save
> self.save_base(using=using, force_insert=force_insert,
> force_update=force_update)
>   File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py",
> line 553, in save_base
> result = manager._insert(values, return_id=update_pk, using=using)
>   File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py",
> line 195, in _insert
> return insert_query(self.model, values, **kwargs)
>   File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py",
> line 1436, in insert_query
> return query.get_compiler(using=using).execute_sql(return_id)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py",
> line 791, in execute_sql
> cursor = super(SQLInsertCompiler, self).execute_sql(None)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py",
> line 735, in execute_sql
> cursor.execute(sql, params)
>   File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py",
> line 34, in execute
> return self.cursor.execute(sql, params)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py",
> line 234, in execute
> return Database.Cursor.execute(self, query, params)
> DatabaseError: table devLab_subfoo has no column named mybar_id

>
>
> I cannot figure out why I get this error.
> thank in advance for any help.
>
>

If you drop the database (or just 'devLab_subfoo') and re-create it
(re-run syncdb) does the error persist?

Looking at the generated SQL, it looks like the table should have that
field. Did you create the database earlier, and then alter the models?
Django will not automatically change the DB structure when running
"syncdb", it will only create tables that are missing.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: need help with postgres installation and set-up for doing tutorials

2012-11-20 Thread Bill Freeman
On Mon, Nov 19, 2012 at 6:40 PM, Luisa Beck  wrote:

> Hi, I'm new to web development and I'm trying to get my mac set up for
> doing the tutorials.
> I installed postgres and pgAdmin III and set it up on the default port
> (5433). I created a test database. Now when I try to open it on the local
> server, I get an error message: 'ERROR: column "datconfig" does not exist
> LINE1:...b.dattablespace AS spcoid, spcname, datallowconn, dataconfig,...
>
> Here is what I did before I closed pgAdmin and then reopened it:
>
>- Installation: The Setup told me that an existing data directory was
>found at /Library/PostgreSQL/9.2/data set to use port 5433.
>- I loaded an .sql file that I wanted to test (I saved it on my
>desktop and loaded it into the database from there).
>
> Also, I'm having trouble entering freenode because it says that " #Django 
> Cannot
> join channel (+r) - you need to be identified with services"
>
> And lastly, if someone could forward me a tutorial about how the
> databases, python files,
> virtual environments and Django work together (I am new to all of these)
> that would be much appreciated!
>
> Thanks in advance!
> Luisa
>
>
> I'm no Mac expert, but I'll offer a couple of thoughts.

First, you shouldn't need to solve both the PostgreSQL installation issue
and learning Django at the same time.  sqlite3 is adequate to the tutorial,
and is built in to modern pythons (e.g.; 2.7), and I presume that's true on
the Mac as well.

Django is written in Python, which requires no pre-compilation, but must be
run with a python interpreter, e.g.; "python manage.py runserver" at the
command line.  The tutorial is written with the assumption that you will be
running it from the command line.  If you have more than one python
installed on your system, you can specify which one to use by including the
path on the command line, such as "~/bin/python manage.py runserver", or
you can adjust your $PATH environment variable so that the correct python
occurs first on the path.  This last is what virtualenv does: the activate
code (which you must "source", not run, e.g.; "source
~/venvs/djtutorial/bin/activate") adjusts the PATH (and prompt) of the
shell that sources it so that the virtualenv's python is found first*, and
defines a "deactivate" shell function that will undo the changes (exiting
the shell is just as good - i.e., this will not last across a reboot, you
must activate each new shell - command line window - that you start to work
on this project).  Python figures out where you ran it from, and searches
from there for it's libraries, and finds first those associated with the
virtualenv, e.g. "~/venvs/djtutorial/lib/python2.7/".  This means that you
can install things there (e.g.; by using "pip install ..." from a shell
that has been activated for that virtualenv) and they won't effect your
base python installation.

[ * Perhaps not commonly understood, you don't need to activate if you
specify the path to the correct python, e.g.;
"~/venvs/djtutorial/bin/python manage.py runserver", so it is easy to
create a shell script or even an alias that does your most common stuff.
For example, you might make a copy of manage.py, maybe called "manage", add
a first line with the magic incantation:

#!/absolute/path/to/the/correct/python

Then make that file executable ("chmod a+x manage") and you will be able to
do "./manage runserver", etc., whether or not you have activated in the
current shell.  (I specifically recommend against putting the project
directory on your path, thus the "./" part.) ]

For most databases Django connects to the database's socket to
communicate.  For sqlite3 the code is running within your python
interpreter and it reads and writes the specified file for persistence.
Django's ORM maps models onto database tables and the fields of the model
onto the columns of the table, and provides the "syncdb" command for
initializing the tables.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: how to use get_queryset in my code

2012-11-20 Thread Nebros
Ok, what is my task...
I have my first page called "Portal". i can give there in a variable, and 
can send the value with this form to the next page. I tryed now to use this 
value as a variable you can see here: 
 
AND (x.t_user = %r)" %x
 
this %x have to be my value of page one, i have given. I know this code:
 
 cnxn = pyodbc.connect('DRIVER={SQL 
Server};SERVER=MAURITIUS;DATABASE=baan5c;UID=***;PWD=*')
cursor = cnxn.cursor()
cursor.execute("SELECT x.t_name, y.t_mail FROM tttaad20 as x, 
tttcmf20 as y WHERE (x.t_name = y.t_name) AND (x.t_user = %r)" %x)
row = cursor.fetchall()
 
give me out data like this:
 
[('Ackermann Marcel (THA) ', ***@***.ch '), ('Adami Renate (HEI) ', 
***@***.ch '), ('Ammann Cornelia (HEI) ', '***@***.ch '), ('Ausbildung A. 
Schwaller (HEI) ', '***@***.ch '),
 
And now the two questtions:
1. How can i set my value of the form as the variable %x?
and
2. How can i give out my data as a table to my page "Kundendaten"?
 
Ignore my fails like:
---
def kundendaten(request):
def get_queryset(self):
kunde = self.request.GET.get("kunde", False)
--
i was trying something, cause i dont know how... ^^
 

Am Dienstag, 20. November 2012 11:10:06 UTC+1 schrieb Daniel Roseman:

> On Tuesday, 20 November 2012 07:25:55 UTC, Nebros wrote:
>
>> I can really need your help, i don't have found the solution till now. :( 
>>
>
> You've had no replies because no-one can understand what you're asking. 
> Something about querysets, but you seem to be using raw SQL in your 
> code, for no apparent reason. And your code is totally unclear: what is 
> that nested function doing, and why does it refer to `self`? And why is it 
> calling itself?
>
> Please post a *minimal* example that shows the problem, and describe 
> exactly what you want to achieve and exactly what is going wrong, including 
> any errors you receive.
> --
> DR.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/yUGGDY4NWOAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: how to use get_queryset in my code

2012-11-20 Thread Martin J. Laubach
  Okay. You seem to be rather confused about the django approach to things 
I'm afraid.

  (a) You use raw sql instead of django's ORM mapper. That's okayish, but 
then you're on your own for building your queries and have to manually do 
validation and escaping and whatnot, which is, as you noticed, a pain in 
the behind.

  (b) You chose to manually build and parse the form. That's okayish, but 
then you're on your own validating user input.

  I strongly suggest you read up on django models 
(https://docs.djangoproject.com/en/1.4/topics/db/models/) and django forms 
(https://docs.djangoproject.com/en/1.4/topics/forms/), which will do most 
of what you want without you reimplementing everything from scratch. What 
you've shown looks more like some converted php code than a native django 
application.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/5crW4d611CcJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: how to use get_queryset in my code

2012-11-20 Thread Nebros
I tryed first this part with db models. but mssql doesnt work on it... i 
cant generate the model by themself. thats why i made it by my own. in 
addition, the next part of my program is to implements lotus notes db... i 
can do it on the same way, thats why i try to do this.
And yes, i create my own, but its not like php. :)
so pls just help me by this problem, cause i do not know everything about 
programming with django.
 

Am Dienstag, 20. November 2012 14:39:07 UTC+1 schrieb Martin J. Laubach:

>   Okay. You seem to be rather confused about the django approach to things 
> I'm afraid.
>
>   (a) You use raw sql instead of django's ORM mapper. That's okayish, but 
> then you're on your own for building your queries and have to manually do 
> validation and escaping and whatnot, which is, as you noticed, a pain in 
> the behind.
>
>   (b) You chose to manually build and parse the form. That's okayish, but 
> then you're on your own validating user input.
>
>   I strongly suggest you read up on django models (
> https://docs.djangoproject.com/en/1.4/topics/db/models/) and django forms 
> (https://docs.djangoproject.com/en/1.4/topics/forms/), which will do most 
> of what you want without you reimplementing everything from scratch. What 
> you've shown looks more like some converted php code than a native django 
> application.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/GgVsgJdB--oJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

2012-11-20 Thread Cj Taylor
Correct, Sergiy.  As I fiddle with this nightly, the core of my issue seems 
to be that mysqldb is not yet python3 ready and django 1.5 is calling for 
it.  I changed my database settings in settings.py to '
django.db.backends.mysql' which in return calls for mysqldb when I do:

python manage.py syncdb


I suppose at this point I'm just seeking anyone who has tried to run django 
1.5 and has MySQL actually working.  If so, how?

On Tuesday, November 20, 2012 2:08:37 AM UTC-5, Sergiy Khohlov wrote:
>
> Which version of django ? 
>  Is this one version has python 3.x support ? 
>
> 2012/11/20 Cj Taylor >: 
> > ok, so what needs to happen here?  Do I need to recode 
> > /usr/local/lib/python3.2/dist-packages/django/db/backends/mysql/base.py 
> to 
> > use this new module? 
> > 
> > 
> > On Sunday, November 18, 2012 4:57:02 PM UTC-5, iñigo medina wrote: 
> >> 
> >> 
> >> On Sat, 17 Nov 2012, Cj Taylor wrote: 
> >> 
> >> > That package installs into my python directory but not python3.  I'm 
> >> > currently trying to get Django 1.5 to work with python3.  Are there 
> >> > other 
> >> > ways currently to get mysql to work with django and the python3 
> >> > environment? 
> >> 
> >> Check out pymysql: 
> >> https://github.com/petehunt/PyMySQL/ 
> >> 
> >> i� 
> >> 
> >> > 
> >> > Try this : 
> >> > 
> >> >> sudo apt-get install python-mysqldb 
> >> >> 
> >> >> -- 
> >> >> Sandeep Kaur 
> >> >> E-Mail: mkaur...@gmail.com  
> >> >> Blog: sandymadaan.wordpress.com 
> >> >> 
> >> > 
> >> > -- 
> >> > You received this message because you are subscribed to the Google 
> >> > Groups "Django users" group. 
> >> > To view this discussion on the web visit 
> >> > https://groups.google.com/d/msg/django-users/-/VfrRmTUUQrgJ. 
> >> > To post to this group, send email to django...@googlegroups.com. 
> >> > To unsubscribe from this group, send email to 
> >> > django-users...@googlegroups.com. 
> >> > For more options, visit this group at 
> >> > http://groups.google.com/group/django-users?hl=en. 
> >> > 
> >> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msg/django-users/-/25S322O0_YkJ. 
> > 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > To unsubscribe from this group, send email to 
> > django-users...@googlegroups.com . 
> > For more options, visit this group at 
> > http://groups.google.com/group/django-users?hl=en. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/rwaVmDBLz_8J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



how i do a update in django QuerySet like this: update table t set col_a = col_a + 2 where col_b = 1

2012-11-20 Thread peixinchen
how i do a update in django QuerySet like this: update table t set col_a = 
col_a + 2 where col_b = 1,

i could use filter take the place of "where clause", but how "set col_a = 
col_a + 2" to being?


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/sA3EewkTS1EJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: how to use get_queryset in my code

2012-11-20 Thread Tom Evans
On Tue, Nov 20, 2012 at 2:07 PM, Nebros  wrote:
> so pls just help me by this problem, cause i do not know everything about
> programming with django.

The problem is that there is a lot going wrong in your code than just
not knowing Django.

I would recommend some python training, or a good book on python in
your native language. I'd also repeat what Martin told you, you are
using Django without using the features in Django that make it
worthwhile using Django. This will make life very hard for yourself,
as you are seeing.

Anyhow, to your code:

> def kundendaten(request):
> def get_queryset(self):
> kunde = self.request.GET.get("kunde", False)
> if kunde == "all":
> kunde = False
> if kunde:
> variable = kunde
> return get_queryset(variable)

What is this function - get_queryset() -  supposed to do? It has an
argument of 'self', but this is not inside a class, so using self is
misleading. You never call this function, which is a good thing as it
never returns anything and recurses into itself. Calling this function
in python would lead to python crashing with a RuntimeError for
reaching maximum recursion depth.

> variable ="x"
> cnxn = pyodbc.connect('DRIVER={SQL
> Server};SERVER=MAURITIUS;DATABASE=baan5c;UID=***;PWD=*')
> cursor = cnxn.cursor()
> cursor.execute("SELECT x.t_name, y.t_mail FROM tttaad20 as x,
> tttcmf20 as y WHERE (x.t_name = y.t_name) AND (x.t_user = %r)" %x)

C'mon. This code doesn't even run does it? It should blow up at this
point with a NameError - you have a variable called 'variable' that
has a value of 'x', but you have no variable called 'x'.

Forgetting that. you've got a cursor there. Cursors all behave
according to the Python DB API, which has methods of specifying
arguments you want inserted into the query:

http://wiki.python.org/moin/DbApiFaq

The reason we use an API, is that they do some of the hard bits of
using a database for you. By manually constructing the SQL string, you
are allowing the opportunity for SQL injection. This is something the
DB API would handle for you. It's also handled if you were using
Django's ORM (which we use as it does ALL the hard bits for us).

Using the DB API seems quite challenging, even if experienced, which
is why we use Django's ORM. You would be better spent getting the ORM
to work with your setup than hacking in bits like this. If you are
going to continue to write your own SQL, it might also be worth
looking up what a JOIN is.

> row = cursor.fetchall()

As I understand it 'row' is in fact multiple rows. It makes sense to
use plural names when appropriate.

> now = datetime.datetime.now()
>
> return render_to_response("kundendaten.html", { 'row':
> row,'current_date': now}, context_instance=RequestContext(request))


Now the template:

> {% include "header.html" %}
> Kundendaten
> {% include "header2.html" %}
> Portal
> Ausgabe Kundendaten
> {% block content1 %}Zeit der Aktualisierung {{ current_date }}{%
> endblock %}

{% block %} allows you to define parts of a template that get replaced
by a template that inherits from this one. Typically, rather than
include multiple header and footer templates, you would instead define
one base template, that has blocks for your title, your content, etc.

The template each view renders is then an derived version of this base
template, and the named blocks in the parent template are replaced by
the same named blocks in the child template.

If you aren't using template inheritance, then the block tag is
irrelevant and has no meaning.

> {% block content2 %}Kundendaten {{ row }}.{% endblock %}
> 
> 
> Name
> E-Mail
> 
> {% for t_name in row %}
> 
> {{ row.t_name }}
> {{ row.t_mail }}
> 
> {% endfor %}

"for val in list" iterates through 'list' yielding a context variable
named 'val' in each iteration of the loop. Your list is called 'row',
which is a list of tuples, which you extracted from the database, and
you call the per-loop variable 't_name'. Yet inside the loop, you
never refer to 't_name' and instead try to lookup attributes from your
list of rows called 'row'. This is not going to work.

Remember when I said use plural names for plural objects? If your list
of rows was called 'rows', that line would read 'for row in rows',
which makes a lot more sense.


So, apart from all the bugs, is what you are trying to do is add a
parameter specified in the GET parameters in the request into that SQL
query?

kunde = request.GET.get("kunde", 'your default "kunde"')
sql = """
SELECT x.t_name, y.t_mail
FROM tttaad20 as x, tttcmf20 as y
WHERE (x.t_name = y.t_name)
AND (x.t_user = ?)
"""
cursor.execute(sql, kunde)

Even if your project means you cannot use Django's ORM, I would still
setup a simple full-stack Django project, do the tutorial and
experiment a bit, in order to give you a bit of experience actually
using Django and understanding 

Re: django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

2012-11-20 Thread Tom Evans
On Tue, Nov 20, 2012 at 2:14 PM, Cj Taylor  wrote:
> Correct, Sergiy.  As I fiddle with this nightly, the core of my issue seems
> to be that mysqldb is not yet python3 ready and django 1.5 is calling for
> it.  I changed my database settings in settings.py to
> 'django.db.backends.mysql' which in return calls for mysqldb when I do:
>
> python manage.py syncdb
>
>
> I suppose at this point I'm just seeking anyone who has tried to run django
> 1.5 and has MySQL actually working.  If so, how?
>

I guess this is the meaning of 'experimental support'. Patches are
probably welcome, or you could use sqlite or postgres.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Building an API to facilitate a mobile app

2012-11-20 Thread Bill Freeman
On Mon, Nov 19, 2012 at 7:08 PM, Amrutha Rajiv wrote:

> Hey All,
> I posted this on the django-tastypie group and I haven't got a response
> yet. I hope there's someone here who can help me with this:
>
> I have a django project that is currently accessible through a web client.
> What I need to do is create API end points to it so that a mobile app can
> send GET & POST requests to it and get back JSON responses. After doing a
> lot of research I've come to a conclusion that django-tastypie is the way
> to go.
> I have existing view functions for my web service that enables a user to
> login & submit a report of sorts. I want the API URLs I add to the project
> to hit the same view functions too. This is where I am stuck. I would
> greatly appreciate it if someone can point to me any documentation that
> explains how to do this. I've searched a lot to find information on this
> but I did not find anything relevant, maybe I searched for the wrong
> things. tastypie does allow me use existing code, right?
>
> Alternatively, I tried django-dynamic-response but I could not get it to
> work and I didn't find much documentation related to that either. Is there
> any other framework that will serve my purpose?
>
> Thanks in advance!
>
> Amrutha
>
>
> I'm not certain what you mean by "same views", but request.is_ajax() may
help if you want to detect the ajax case and pass it off to the tastypie
back end (by calling a view from there and returning what it returns).

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: how i do a update in django QuerySet like this: update table t set col_a = col_a + 2 where col_b = 1

2012-11-20 Thread Tom Evans
On Tue, Nov 20, 2012 at 1:00 PM, peixinchen  wrote:
> how i do a update in django QuerySet like this: update table t set col_a =
> col_a + 2 where col_b = 1,
>
> i could use filter take the place of "where clause", but how "set col_a =
> col_a + 2" to being?
>

from django.db.models import F
Foo.objects.filter(col_b=1).update(col_a=F('col_a')+2)

https://docs.djangoproject.com/en/1.4/topics/db/queries/#query-expressions

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Using South with Custom User Model

2012-11-20 Thread Chris Pagnutti
I'm wondering if anyone has ever had success with using South when you have 
AUTH_USER_MODEL set to a custom User model.  I've made various attempts, 
which are basically all the same steps but in different orders.
Basically, my problems is related to this ticket

http://south.aeracode.org/ticket/1179

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/kdlkey4FboEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django admin site

2012-11-20 Thread Valentin Rozescu


I am going step by step in the tutorial "Writing your first Django app" 
(https://docs.djangoproject.com/en/dev/intro/tutorial01/) 
but in the part 2, step creating admin site, I'm blocked because of the 
fact that I cannot login to the administration site.

I create a superuser with manage.py createsuperuser but I receive 
continuously the error about wrong username or password.

Please give me some advise in this respect. I want to evaluate Django and I 
am exited about the features and posible benefits by using it.

I am looking forward for your answer.
Best regards,
Valentin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Gw6cb9x7TXMJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to implement pre-save operations for inlines in the admin interface?

2012-11-20 Thread Carsten Fuchs

Just for info, to complete this:

I read in the admin interface source code (contrib/admin/options.py) and 
found a solution myself. It's not as clear and straightforward as one 
would wish, but simple and robust:


We now simply override the `ModelAdmin.save_formset()` function like this:


def save_formset(self, request, form, formset, change):
if formset.model == Period:
# Save normally.
instances = formset.save()

if instances:
# At least *one* period has changed and was saved,
# so check/update *all* periods of that staff member.
instances[0].staff.UpdateAllPeriods()
else:
# The default implementation of save_formset():
formset.save()


(The ugly trick is the `instances[0].staff` to obtain the parent object.)

Function `UpdateAllPeriods()` simply loops over the `period_set` of the 
Staff instance and updates the periods as required.


:-)

Best regards,
Carsten



--
   Cafu - the open-source Game and Graphics Engine
for multiplayer, cross-platform, real-time 3D Action
  Learn more at http://www.cafu.de

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: ModelAdmin.save_formset() questions

2012-11-20 Thread Carsten Fuchs

Unfortunately, no replies here, but to tie the loose ends up:
I found a solution that I posted in the thread of my original problem:
https://groups.google.com/d/topic/django-users/ZwgW7-t6CBA/discussion

Best regards,
Carsten



--
   Cafu - the open-source Game and Graphics Engine
for multiplayer, cross-platform, real-time 3D Action
  Learn more at http://www.cafu.de

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django in virtualenv + nginx + uwsgi set up guide

2012-11-20 Thread abidibo
I'm glad you enjoy my post series, good work all!

On Saturday, 17 November 2012 01:34:56 UTC+1, Chris Pagnutti wrote:
>
> Yep.  I got the server up and running, and that was definitely the most 
> useful resource.  Thanks.
>
> On Fri, Nov 16, 2012 at 5:30 PM, I単igo Medina 
> 
> > wrote:
>
>>
>> Thanks for sharing. Good reference. :)
>>
>> iñ
>>
>> --**-
>> grosshat.com
>> Servicios de desarrollo web, usabilidad y sistemas
>>
>>
>> On Fri, 16 Nov 2012, Leonardo M. Millefiori wrote:
>>
>>  Hi Chris,
>>> you may get some ideas from this long guide, which is fairly recent:
>>>
>>> [1]
>>> http://www.abidibo.net/blog/**2012/04/30/deploy-django-**
>>> applications-nginx-uwsgi-**virtualenv-south-git-and-**fabric-part-1/
>>> [2]
>>> http://www.abidibo.net/blog/**2012/05/23/deploy-django-**
>>> applications-nginx-uwsgi-**virtualenv-south-git-and-**fabric-part-2/
>>> [3]
>>> http://www.abidibo.net/blog/**2012/06/04/deploy-django-**
>>> applications-nginx-uwsgi-**virtualenv-south-git-and-**fabric-part-3/
>>> [4]
>>> http://www.abidibo.net/blog/**2012/06/20/deploy-django-**
>>> applications-nginx-uwsgi-**virtualenv-south-git-and-**fabric-part-4/
>>> [5]
>>> http://www.abidibo.net/blog/**2012/06/29/deploy-django-**
>>> applications-nginx-uwsgi-**virtualenv-south-git-and-**fabric-part-5/
>>>
>>> It helped me a lot, and it's very complete, covering also fabric tool.
>>>
>>> Enjoy it, and good luck!
>>>
>>>
>>> 2012/11/9 Chris Pagnutti >
>>>
>>>  Hi.  I'm looking for a recent guide for setting up nginx to serve django
 projects in a virtualenv via uwsgi.  I can find a whole pile of them, 
 but
 they're all so different, and some are dated.  I'm looking for something
 complete and recent that actually works.  Ideally, I'd like it to be 
 for a
 Debian-based system, but I think if the guide is good, I should be able 
 to
 do it for any distro.

 Thanks a whole bunch.

 --
 You received this message because you are subscribed to the Google 
 Groups
 "Django users" group.
 To view this discussion on the web visit
 https://groups.google.com/d/**msg/django-users/-/oqNciN_**d9QUJ
 .
 To post to this group, send email to 
 django...@googlegroups.com
 .
 To unsubscribe from this group, send email to
 django-users...@**googlegroups.com .
 For more options, visit this group at
 http://groups.google.com/**group/django-users?hl=en
 .

  
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To post to this group, send email to django...@googlegroups.com
>>> .
>>> To unsubscribe from this group, send email to django-users...@**
>>> googlegroups.com .
>>> For more options, visit this group at http://groups.google.com/**
>>> group/django-users?hl=en
>>> .
>>>
>>>
>>>  
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to django-users...@**
>> googlegroups.com .
>> For more options, visit this group at http://groups.google.com/**
>> group/django-users?hl=en
>> .
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/kh6jokDHcg8J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: missing column name in subclasses

2012-11-20 Thread Emmanuel Jannetti
Hi,

If you drop the database (or just 'devLab_subfoo') and re-create it 
>
dropping the DB did the trick

Just found out that 'python manage.py flush --noinput '  followed by 
'manage.py syncdb'   is not enough.


 

> (re-run syncdb) does the error persist? 
>
> Looking at the generated SQL, it looks like the table should have that 
> field. Did you create the database earlier, and then alter the models? 
> Django will not automatically change the DB structure when running 
> "syncdb", it will only create tables that are missing. 
>
>
Running "python manage.py reset "  did the trick. 

I should have dig further into definition of  'flush' , 'syncdb' and 
'reset'  commands ...

thank for the help and sorry for disturbance.

manu

 

> Cheers 
>
> Tom 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/qPFZ3t5WVU0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



FactoryBoy & ManyToManyField

2012-11-20 Thread Craig Blaszczyk
Hi Guys,

I'm using FactoryBoy in my tests, but I have a model which has 
a ManyToManyField to another model. Does anyone know if it's possible to 
make factoryboy use a factory to represent this relationship?

For reference, here are a sample model and factory:

--models.py
from django.contrib.auth.models import User
from django.db.models import ManyToManyField
class Workplace(models.Model):
employees = ManyToManyField(User)

--tests.py
import factory
from models import Workplace

# This will set the default strategy for all factories that don't define a 
default build strategy
factory.Factory.default_strategy = factory.BUILD_STRATEGY

class WorkplaceFactory(factory.Factory):
FACTORY_FOR = Workplace


class UserFactory(factory.Factory):
FACTORY_FOR = User


class ATestCase(TestCase):

def setUp(self):
super(ATestCase, self).setUp()
self.user = UserFactory.build()
self.workplace = WorkplaceFactory.build()

def test_foobar(self):
# how do I add self.user to self.workplace ?
self.assertEqual(self.workplace.employees_set.all(), 1)



--Craig

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Aubjg6DsgoYJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Is there a recommended pattern for creating "replaceable" apps?

2012-11-20 Thread Chris Cogdon


On Monday, November 19, 2012 9:36:40 PM UTC-6, Russell Keith-Magee wrote:
>
>
> See the development docs for custom user models to see how this works in 
> practice, and adapt for your purposes. I'm intentionally going to leave the 
> rest vague. Call it an entrance exam -- if you can't work out what's going 
> on from what I've given you here and reading Django's source code, you 
> probably shouldn't be playing around with this sort of experimental 
> feature. However, I'm happy to answer specific questions if you get stuck 
> deep in the grass.
>
> Once again, I must stress that this is unofficial, and you'll be in 
> experimental territory if you do this. The reason this is unofficial is 
> because some on the core team are concerned about reopening old wounds -- 
> essentially, swapping models can lead to all sorts of headaches, and the 
> Django project has had these headaches in the past. Consider, for example, 
> if a user changes the CUSTOM_PERSON_MODEL after they've synchronised. 
> Hilarity *will* ensue. There's also problems related to forms and setting 
> an implied contract around your swappable model.
>
> However, it *can* work; and to my mind, we're all consenting adults, so as 
> long as we all understand the potential pitfalls, this is the sort of thing 
> that may be useful. 
>
> If I haven't scared you off by this point, I certainly hope you'll have a 
> tinker and see if this might be palatable for your project.
>

Sorry, not scared me off yet :) I'll go take a look at that code. I *was *aware 
of the replaceable User model, but didn't consider that perhaps this was 
also setting a standard framework for any replaceable model.

If the framework is simple enough, I could gear my own application to use 
it and dropship code from 1.5 into my own project, much like Django 
dropshipped dictconfig for the logging module.

Thanks for the reference, and I'll shoot you questions if/when I have them.


>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/3x1_N94W7AwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django admin site

2012-11-20 Thread I単igo Medina

On Tue, 20 Nov 2012, Valentin Rozescu wrote:




I am going step by step in the tutorial "Writing your first Django app" 
(https://docs.djangoproject.com/en/dev/intro/tutorial01/)
but in the part 2, step creating admin site, I'm blocked because of the
fact that I cannot login to the administration site.

I create a superuser with manage.py createsuperuser but I receive
continuously the error about wrong username or password.

Please give me some advise in this respect. I want to evaluate Django and I
am exited about the features and posible benefits by using it.


Did you add the 'django.contrib.admin' to INSTALLED_APPS? Did you run
`syncdb` for creating the data model? On that step you would be asked to enter
admin user and password.

iń



I am looking forward for your answer.
Best regards,
Valentin

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Gw6cb9x7TXMJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: how to use get_queryset in my code

2012-11-20 Thread Martin J. Laubach

>
> I tryed first this part with db models. but mssql doesnt work on it...
>

  BTW, why? I see there's a django-mssql, that should allow you to connect 
to the database. Doesn't it work with your version? I've never tried it 
though, I just googled around a bit...

 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/jqMkjNjcZo4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Installing PyBB

2012-11-20 Thread Yogev Metzuyanim
Hi
I intalled PyBB with easy install, after adding it to the INSTALLED_APPS, i 
run syncdb and get the following error:
AtrributeError: 'Settings' object has no attribute 'PYBB_DEFAULT_MARKUP'.
Does anyone know what did I do wrong?
Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/8thfxI89evQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django admin site

2012-11-20 Thread Yogev Metzuyanim
What database are you using?

On Tuesday, November 20, 2012 5:49:40 PM UTC+2, Valentin Rozescu wrote:
>
> I am going step by step in the tutorial "Writing your first Django app" (
> https://docs.djangoproject.com/en/dev/intro/tutorial01/) but in the part 
> 2, step creating admin site, I'm blocked because of the fact that I cannot 
> login to the administration site.
>
> I create a superuser with manage.py createsuperuser but I receive 
> continuously the error about wrong username or password.
>
> Please give me some advise in this respect. I want to evaluate Django and 
> I am exited about the features and posible benefits by using it.
>
> I am looking forward for your answer.
> Best regards,
> Valentin
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/AJp0TD0P6BgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



login page shouldn't open when I am already logged in, but it does !

2012-11-20 Thread Loai Ghoraba
Hi all

I am trying to build a login page using Django auth app, it is all working 
nice but there is one problem: If I browse to accounts/login (the login 
url) when I am already logged in, in normal situation the login view 
shouldn't be rendered and the correct action will be to redirect to the 
home page/the request url/etc..

But this just doesn't happen ! It renders the login view normally as if I 
am not logged in!
I even checked the source code, and indeed it doesn't check whether the 
user is already logged in.

So is this a bug or something ?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/YtY426bWAiUJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django web app pages not displaying

2012-11-20 Thread coded kid
I just deployed my django website, I tried visiting some pages on the
site and it's not displaying. I have three web browsers on my PC, I
tried visiting those pages through the other two web browsers but the
pages are not displaying. I asked a friend of mine in Poland to check
those pages out, he said the pages are displaying.

Before I deploy, everything is running fine on my local server. But
after I deployed some pages are not showing. and django didn't send me
any error mail concerning the site.

How can I go about solving this problem? Would be glad to hear your
opinion on this.

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Installing PyBB

2012-11-20 Thread carlos
read de documentation
http://packages.python.org/pybb/
or send mail for the author :/

cheers

On Tue, Nov 20, 2012 at 11:15 AM, Yogev Metzuyanim wrote:

> Hi
> I intalled PyBB with easy install, after adding it to the INSTALLED_APPS,
> i run syncdb and get the following error:
> AtrributeError: 'Settings' object has no attribute 'PYBB_DEFAULT_MARKUP'.
> Does anyone know what did I do wrong?
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/8thfxI89evQJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django web app pages not displaying

2012-11-20 Thread Yogev Metzuyanim
Thanks, I needed to add this line: from pybb.settings import * to my 
settings file.
But now I have another problem, as I follow the instruction from the link 
you gave me, I'm trying to run this command: manage.py 
pybb_created_related_objects
and i get the following error: TypeError: get_db_prep_value() got an 
unexpected keyword argument 'connection'
I google it and apparently it happens because the move from django 1.3 to 
1.4, but I don't know what to do to fix it.

On Tuesday, November 20, 2012 8:56:54 PM UTC+2, coded kid wrote:
>
> I just deployed my django website, I tried visiting some pages on the 
> site and it's not displaying. I have three web browsers on my PC, I 
> tried visiting those pages through the other two web browsers but the 
> pages are not displaying. I asked a friend of mine in Poland to check 
> those pages out, he said the pages are displaying. 
>
> Before I deploy, everything is running fine on my local server. But 
> after I deployed some pages are not showing. and django didn't send me 
> any error mail concerning the site. 
>
> How can I go about solving this problem? Would be glad to hear your 
> opinion on this. 
>
> Thanks. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/au8S5-UlWbwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Installing PyBB

2012-11-20 Thread Yogev Metzuyanim
Thanks, I needed to add this line: from pybb.settings import * to my 
settings file.
But now I have another problem, as I follow the instruction from the link 
you gave me, I'm trying to run this command: manage.py 
pybb_created_related_objects
and i get the following error: TypeError: get_db_prep_value() got an 
unexpected keyword argument 'connection'
I google it and apparently it happens because the move from django 1.3 to 
1.4, but I don't know what to do to fix it.

On Tuesday, November 20, 2012 9:10:40 PM UTC+2, sacrac wrote:
>
> read de documentation 
> http://packages.python.org/pybb/
>   
> or send mail for the author :/
>
> cheers
>
> On Tue, Nov 20, 2012 at 11:15 AM, Yogev Metzuyanim 
> 
> > wrote:
>
>> Hi
>> I intalled PyBB with easy install, after adding it to the INSTALLED_APPS, 
>> i run syncdb and get the following error:
>> AtrributeError: 'Settings' object has no attribute 'PYBB_DEFAULT_MARKUP'.
>> Does anyone know what did I do wrong?
>> Thanks.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/8thfxI89evQJ.
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/vzjn6vaTMmYJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django web app pages not displaying

2012-11-20 Thread Babatunde Akinyanmi
Hi coded,
What error is your browser complaining of? "Connection timed out" or
"Server Not Found"??

On 11/20/12, coded kid  wrote:
> I just deployed my django website, I tried visiting some pages on the
> site and it's not displaying. I have three web browsers on my PC, I
> tried visiting those pages through the other two web browsers but the
> pages are not displaying. I asked a friend of mine in Poland to check
> those pages out, he said the pages are displaying.
>
> Before I deploy, everything is running fine on my local server. But
> after I deployed some pages are not showing. and django didn't send me
> any error mail concerning the site.
>
> How can I go about solving this problem? Would be glad to hear your
> opinion on this.
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
Sent from my mobile device

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Login failing

2012-11-20 Thread Aryeh Leib Taurog
> On Feb 22, 11:34 pm, "Aryeh Leib Taurog"  wrote:
>> I'm seeing a very strange intermittent problem with logging in.  The login
>> appears to be successful, because the response to the login POST is a 302
>> redirect.  However sometimes the user doesn't seem to be stored in the
>> session.
>>
>> I'm running:
>> django 1.2.4
>> python 2.6.5 (ubuntu 10.4)
>> lighttpd 1.4.26 via fcgi (with flup)
>> postgresql 8.4 via psycopg2 (2.0.13-2ubuntu2)
>>
>> session engine is db (all session-related settings are default)
>> The login view is django.contrib.auth.views.login
>>
>> MIDDLEWARE_CLASSES = (
>>     'django.middleware.common.CommonMiddleware',
>>     'django.contrib.sessions.middleware.SessionMiddleware',
>>     'django.middleware.csrf.CsrfViewMiddleware',
>>     'django.middleware.locale.LocaleMiddleware',
>>     'django.contrib.auth.middleware.AuthenticationMiddleware',
>>     'django.contrib.messages.middleware.MessageMiddleware',
>>     'django.middleware.doc.XViewMiddleware',
>>     'django.middleware.transaction.TransactionMiddleware',
>>      ...
>> )

I'm reviving this monologue because I believe I've resolved the issue, and
perhaps the information will be of use to someone else.  I concluded that the
login failures were the result of db connections left with uncommitted
transactions: 

I was using transaction middleware, so this issue did not affect most normal 
activity on the site.  But authentication and session middleware were outside
the transaction middleware, so the problem became apparent there.  I imagine
one solution would have been to move the transaction middleware outside the
session and authentication middleware. 
 
I opted for postgresql 'autocommit' mode, as Christophe Pettus recommends:


In order for this to work I had to apply the patch for this bug (I'm running
django 1.3.1 at the moment): 

It's been a few weeks since the fix was applied.  I've seen no issues so far,
login-related or otherwise.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Best way to create an advanced search bar for the admin app.

2012-11-20 Thread Nicolas Emiliani
Hi people.

I have this huge class Foo that has a lot of attributes , not only that but
it has
an m2m relation with a through table that specifies values for each
relation,
and I want to be able to search using those values.
For example :

class Foo
 ...
class Attr
 ...

and the

class Has:
foo
attr
value

So basically Foo Has a given Attr with value X. The idea is having on top
of the search
bar at the list form a box that lets you choose (using check boxes) the
attributes and values
for each checked attribute (using text boxes).

My idea was redefining change_list.html to present that and somehow, I do
not know how yet,
override the search method at the admin site.

Does it sound good?
Has anyone done this?
Is there another approach?

Any comments will be highly appreciated.

Thanks!

-- 
Nicolas Emiliani

Lo unico instantaneo en la vida es el cafe, y es bien feo.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Is there a recommended pattern for creating "replaceable" apps?

2012-11-20 Thread Marc Aymerich
On Tue, Nov 20, 2012 at 4:35 AM, Russell Keith-Magee
 wrote:
>
> On Tue, Nov 20, 2012 at 6:28 AM, Chris Cogdon  wrote:
>>
>> Hi folks!
>>
>> I'm creating an application to manage an art show (with art pieces to view
>> and sell, silent and voice auctions, and a sales process). To have this
>> work, it of course needs to keep track of people (including names,
>> addresses, email, etc). But to make this more useful to anyone, I want to
>> include the ability to replace the included "Person" model with another,
>> should the implementor so choose.
>>
>> What I've done so far is to split the Person model into another app
>> (called Peeps) and removed all but a few necessary linkages between the
>> Artshow and Peeps app. It was reasonably simple, but a few things seem
>> "dirty" so I'm wondering if anyone else has a more experienced or
>> authoritative suggestion for this.
>
>
> Ok… so… In Django 1.5, yes there is… unofficially.
>
> Now - I must stress -- everything I'm about to say is 100% undocumented, and
> 100% experimental. If it breaks, you get to keep all the shiny pieces :-)
> I'm only mentioning it because I (personally) need people to experiment in
> this space in order to prove to the core team that the feature is safe for
> public consumption.
>
> With that caveat in place:
>
> In Django 1.5 (i.e., the current development branch), we've added the
> ability to add swappable User models. This means you can replace Django's
> builtin User model with any User model you want -- for example, a user model
> that uses 'email' as the unique identifier, or one that captures API
> credentials rather than first and last name.
>
> The dirty secret is that when I implemented this feature for contrib.auth, I
> did so in a way that was completely independent of the User model itself.
> There aren't any explicit references to contrib.auth in the main model code
> that makes swappable User models possible. In theory *any* model can be
> declared as swappable, which will allow the end user to define that in their
> project the "X" model will be performed by model "Y", and any foreign keys
> will be re-routed appropriately.
>
> The magic sauce: On the model you want to be swappable (Person, in your
> case), add a Meta declaration:
>
> class Person(Model):
> class Meta:
> swappable = 'CUSTOM_PERSON_MODEL'

wow, I'm also taking notes of this :)

-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: ipython 0.11 with django 1.3 /in virtualenv

2012-11-20 Thread Martin
This comment explains why it is not loaded: 
https://code.djangoproject.com/ticket/17078#comment:8

Not sure how to go on from that though.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/_UdpKoy55m4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Request for inspiration on business system

2012-11-20 Thread Peter Edström
Hello,
A short background:
I'm about to develop a web-based portal for my friend's company that deals 
with cleaning services of all kind, and I want to try out Django for this. 
In brief, the portal should consist of a database with data on employees, 
customers, contracts, work orders... and upon this there should be an 
interface for administrating everything related, such as adding customers, 
contracts and so on. There should also be an interface for the employees, 
for viewing work orders, today's agenda (e.g. go to customer X and do task 
Y) and register time put into a work order and closing it. In the 
background, work orders are supposed to be created automatically based on 
what's agreed upon in a contract (e.g. customer X subscribes on task Y on 
interval Z which should be handled by employee A).

A company's internal business database system pretty much, and nothing new 
under the sun. Perhaps accompanied by an external website further on.
Now on to the questions.

   1. Do you think Django would be suitable for this?
   2. Do you have some spontaneous ideas and/or pre-made code snippets that 
   could be handy (like a calendar)?
   3. How would you structure the project;
  - Everything in one app, or how would you split them? One for 
  employee interface, one for admin interface (perhaps use the built-in 
admin 
  system), one for external website? Is this bad design?
  
I would like to design is such that it will be easy to expand, e.g. with 
statistics on hours worked, integration with invoice system, database 
accessible by Android app... or whatever. But being new to Django I'm 
not really comfortable with basic design principles.

Any input is appreciated and of course I'm reading up in Django Book, 
watching YouTube videos and exploring code as much as I can.

Thank you.
Best regards,
Peter

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/geK-jXEjDQEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: login page shouldn't open when I am already logged in, but it does !

2012-11-20 Thread Issam Outassourt
Hi,

Well what you could do actually, and it's of commun use is to give your
user a session-cookie id, which you can generate based on some informations
in the header, typically his login, his ip adress, his password, his
user-agent...
As he tries to get the login page, challenge him by checking if the cookie
is set.
If it is set, you should recompute the value and check wether it matches.
If it does, then you can redirect the response to another url, otherwise
you show back the login page.

Well, i'll give you the structure of the code :

*login page*

if(cookie_session_id is set):

calculate new_cookie_session_id(remarkable data_headers, database
information,...) //through concatenation and hashes
if (new_cookie_session_id == cookie_session_id):
 return redirection_to_main_page
else:
 return
what_should_be_the_template_that_allows_the_user_to_identify_him_self
else:
return
what_should_be_the_template_that_allows_the_user_to_identify_him_self


*submit_page*
/* after the user gets to give his own parameters and submit the form
you should manage the data with a view function that sets the
cookie_session_id for the session */


if(the_user_has_the_right_to_authenticate_with_submitted_values):
 calculate cookie_session_id(remarkable data_headers, database
information,...)
 set cookie_session_id
 return the_user_main_page
else:
 return an_error_and_allow_your_user_to_log_again // or something
of that kind

DONE !
The idea behind that is that if the facility is not offered or you did not
afford the time to check the documentation, you can try to solve your
problem by your own. Yet more, you should consider checking the
cookie_session_id any time the user tries to browse a page that contains
sensitive or not public information. What would help you do so is to add a
widget in all pages that shows the login_form if not logged or
login+photo+profile_link (be creative and make sure you check what happens
security wise) information (template power, if you know what i mean ;))

One thing to add is that to compute the value you're looking for, what is
advised generally is to get important information that you believe identify
well, or uniquely your user, concatenante all the stuff and hash it with
very common hash algorithms such as md5, sha1...
More to it, if you want to make sure that you don't have to calculate the
cookie_session_id each time, all you need is to create a Class that
inherits from models.User, add a ForeignKeyField that holds a list of
couples coming from another table that you create and that can hold the
cookie_session_id of your users and the last_request_date

Class SessionId(models.Model):
  session_hash = models.TextField(whatever options you want)
  last_request_date = models.DateTimeField(feel free to customize)

The purpose of this is to make sure that you update SessionId entries each
time you receive a request, to make sure that outdated connections can be
deleted and to allow your users to connect through different platforms at
the same time, as the value of the cookie_session_id could depend as well
on something unique to each machine (their ip adress for example, and their
user-agent)

So, your structure will change from that thing above to the following :

*login page*

if(cookie_session_id is set):

calculate new_cookie_session_id(remarkable data_headers, database
information,...) //through concatenation and hashes
if (new_cookie_session_id == cookie_session_id,
*and the session is not expired*):
 return redirection_to_main_page
else:
 *make sure that the user is not authenticated and clear
the foreign key entry if needed (that is to say if it exists and the
session is outdated)*
 return
what_should_be_the_template_that_allows_the_user_to_identify_him_self
else:
return
what_should_be_the_template_that_allows_the_user_to_identify_him_self


*submit_page*
/* after the user gets to give his own parameters and submit the form
you should manage the data with a view function that sets the
cookie_session_id for the session */


if(the_user_has_the_right_to_authenticate_with_submitted_values):
 calculate cookie_session_id(remarkable data_headers, database
information,...)
 set cookie_session_id
 *add according entry in the foreignkey field, adding it as well in
the sessionid table*
 return the_user_main_page
else:
 return an_error_and_allow_your_user_to_log_again // or something
of that kind


I hope I gave you sufficient hints.
Feel free to ask for more explanations if needed. I would be happy to help

Regards,


2012/11/20 Loai Ghoraba 

> Hi all
>
> I am trying to build a login page using Django auth app, it is all working
> nice but there is one problem: If I browse to accounts/login (the login
> url) when I am already logged in, in normal situation

Re: FactoryBoy & ManyToManyField

2012-11-20 Thread Andres Reyes Monge
The simplest would be to 

class ATestCase(TestCase):

def setUp(self):
super(ATestCase, self).setUp()
self.user = UserFactory()
self.workplace = WorkplaceFactory()
self.workplace.employees_set.add(self.user)

def test_foobar(self):
# how do I add self.user to self.workplace ?
self.assertEqual(self.workplace.employees_set.all(), 1)


Note that you probably want to use create instead of build so that the 
objects are saved to the database

 
On Tuesday, November 20, 2012 11:36:16 AM UTC-6, Craig Blaszczyk wrote:
>
> Hi Guys,
>
> I'm using FactoryBoy in my tests, but I have a model which has 
> a ManyToManyField to another model. Does anyone know if it's possible to 
> make factoryboy use a factory to represent this relationship?
>
> For reference, here are a sample model and factory:
>
> --models.py
> from django.contrib.auth.models import User
> from django.db.models import ManyToManyField
> class Workplace(models.Model):
> employees = ManyToManyField(User)
>
> --tests.py
> import factory
> from models import Workplace
>
> # This will set the default strategy for all factories that don't define a 
> default build strategy
> factory.Factory.default_strategy = factory.BUILD_STRATEGY
>
> class WorkplaceFactory(factory.Factory):
> FACTORY_FOR = Workplace
>
>
> class UserFactory(factory.Factory):
> FACTORY_FOR = User
>
>
> class ATestCase(TestCase):
>
> def setUp(self):
> super(ATestCase, self).setUp()
> self.user = UserFactory.build()
> self.workplace = WorkplaceFactory.build()
>
> def test_foobar(self):
> # how do I add self.user to self.workplace ?
> self.assertEqual(self.workplace.employees_set.all(), 1)
>
>
>
> --Craig
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/PO1F2ERL5CwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Can't get Web font loader in django

2012-11-20 Thread Chris Pagnutti
Hi.  I'm trying to get the Google Web Font loader via
http://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js";>
in my  section.
But when I load the page I get (in Chromium's console) this message:
GET https://www.googleapis.com/webfonts/v1/webfonts 403 (Forbidden)
HOWEVER, if I call the webfonts.js script in a pure HTML/Javascript page 
(not running behind the django development server) it works fine.

I can request other googleapis resources without problems, e.g.
http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js";>
works fine.

Any ideas about what's going wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/U-KJVz1N_McJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Request for inspiration on business system

2012-11-20 Thread Lachlan Musicman
On Wed, Nov 21, 2012 at 8:37 AM, Peter Edström  wrote:
> Hello,

Hi!

> A company's internal business database system pretty much, and nothing new
> under the sun. Perhaps accompanied by an external website further on.
> Now on to the questions.
>
> Do you think Django would be suitable for this?

Yep!

> Do you have some spontaneous ideas and/or pre-made code snippets that could
> be handy (like a calendar)?

1. Do the tutorial.
2. Set up using virtualenv (for compartmentalising), pip (for
installing) and South (because you will need it as your models
change).
3. djangosnippets.org is a good place to start, and to get ideas.

> How would you structure the project;
> Everything in one app, or how would you split them? One for employee
> interface, one for admin interface (perhaps use the built-in admin system),
> one for external website? Is this bad design?

I would put everything in one app - it's seems small enough that this
will suffice. Too much fragmentation will just cause headaches. I
believe that others will disagree with me on this.

> I would like to design is such that it will be easy to expand, e.g. with
> statistics on hours worked, integration with invoice system, database
> accessible by Android app... or whatever. But being new to Django I'm
> not really comfortable with basic design principles.
>
> Any input is appreciated and of course I'm reading up in Django Book,
> watching YouTube videos and exploring code as much as I can.

Just get started - that's the best way to learn. The number of times I
got halfway through implementing something and then discovered that
there was already a django goody waiting to make life easier for me
(slugify, get_absolute_url, SortedDict, actions...) - but I had to
know what to ask for first. I think jumping in is especially important
if you are new to Django.

Cheers
L.



>
> Thank you.
> Best regards,
> Peter
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/geK-jXEjDQEJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.



--
...we look at the present day through a rear-view mirror. This is
something Marshall McLuhan said back in the Sixties, when the world
was in the grip of authentic-seeming future narratives. He said, “We
look at the present through a rear-view mirror. We march backwards
into the future.”

http://www.warrenellis.com/?p=14314

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django password_reset_email.html not rendering in HTML

2012-11-20 Thread Larry Martell
I have set up the password reset feature, but the email that gets sent
comes in plain text - it does not get rendered in HTML. I googled this
and found this on SO:

http://stackoverflow.com/questions/13285976/python-django-email-template-is-not-rendered-shows-html-tags-and-doesnt-conve/13286215#13286215

But I don't really understand the answer. Where exactly would I add the line:

msg.attach_alternative(t.render(Context({})), "text/html")

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Using South with Custom User Model

2012-11-20 Thread Russell Keith-Magee
Hi Chris,

You've asked if anyone has had success, which implies the thou haven't, but
you haven't said what problem you're having.

My experience (which is logged in the ticket you reference) is that yes,
running convert_to_south raises an error -- but the migration is created
correctly, and works fine if you try to use it. So until the bug is fixed,
you just have to hold your nose when the error is raised, and continue on
as normal.

If you're having a different problem, then we'd need to see details (and
you'll likely get better responses on the South mailing list).

Yours,
Russ Magee %-)


On Wed, Nov 21, 2012 at 12:16 AM, Chris Pagnutti
wrote:

> I'm wondering if anyone has ever had success with using South when you
> have AUTH_USER_MODEL set to a custom User model.  I've made various
> attempts, which are basically all the same steps but in different orders.
> Basically, my problems is related to this ticket
>
> http://south.aeracode.org/ticket/1179
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/kdlkey4FboEJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Can't get Web font loader in django

2012-11-20 Thread Issam Outassourt
{
 "error": {
  "errors": [
   {
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded.
Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console";
   }
  ],
  "code": 403,
  "message": "Daily Limit for Unauthenticated Use Exceeded. Continued
use requires signup."
 }
}


When I follow the link you passed through, I (give it a try) found
this more detailed response.
What you actually need to do is within your view that renders the page
requirements log in to your google
account, retrieve the file, and pass it to your template so it
incorporates your response within the html
web page.

In your head section template all you need to do is something of this kind :

{% for jsscript in jsscript_list %}

{{ jsscript }}

{% endfor %}

assuming that jsscript is the text jsscript that you want to add to
your web page.
You can use pycurl's python module to request the .js file that's needed.

Hope this helped,

Issam



2012/11/21 Chris Pagnutti 

> Hi.  I'm trying to get the Google Web Font loader via
> http://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js";>
> in my  section.
> But when I load the page I get (in Chromium's console) this message:
> GET https://www.googleapis.com/webfonts/v1/webfonts 403 (Forbidden)
> HOWEVER, if I call the webfonts.js script in a pure HTML/Javascript page
> (not running behind the django development server) it works fine.
>
> I can request other googleapis resources without problems, e.g.
> http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js";>
> works fine.
>
> Any ideas about what's going wrong?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/U-KJVz1N_McJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django web app pages not displaying

2012-11-20 Thread coded kid
I set Debug=False. It didn't bring any errors. Also django didn't send an 
error mail to me. The page is just blank.

On Tuesday, 20 November 2012 22:23:14 UTC+1, Tundebabzy wrote:
>
> Hi coded, 
> What error is your browser complaining of? "Connection timed out" or 
> "Server Not Found"?? 
>
> On 11/20/12, coded kid > wrote: 
> > I just deployed my django website, I tried visiting some pages on the 
> > site and it's not displaying. I have three web browsers on my PC, I 
> > tried visiting those pages through the other two web browsers but the 
> > pages are not displaying. I asked a friend of mine in Poland to check 
> > those pages out, he said the pages are displaying. 
> > 
> > Before I deploy, everything is running fine on my local server. But 
> > after I deployed some pages are not showing. and django didn't send me 
> > any error mail concerning the site. 
> > 
> > How can I go about solving this problem? Would be glad to hear your 
> > opinion on this. 
> > 
> > Thanks. 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > To unsubscribe from this group, send email to 
> > django-users...@googlegroups.com . 
> > For more options, visit this group at 
> > http://groups.google.com/group/django-users?hl=en. 
> > 
> > 
>
> -- 
> Sent from my mobile device 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/iKuraHwC36EJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: password reset

2012-11-20 Thread Larry Martell
Just getting back to this now. We were able to get this going on my
client's client's system, but not on my client's test system. There
we're getting errno 111
(https://www.pythonanywhere.com/forums/topic/54/). It would be nice to
have some place to test, but we're not going to go nuts, since the
client is (fairly) happy. The one remaining issue is that the reset
email is not getting rendered in HTML (I send a separate post about
that). Thanks again Russell for all your help!

On Thu, Oct 18, 2012 at 1:44 AM, Larry Martell  wrote:
>
> Thanks for the info. I'm on vacation for 3 weeks. I'll revisit this when I
> return.
>
> On Wednesday, October 17, 2012, Russell Keith-Magee wrote:
>>
>> Hi Larry,
>>
>> Yes - you'll need to configure the SMTP host, port and any login
>> credentials. The exact settings required will depend on how you've got
>> postfix configured, but the full list of settings that *may* be
>> required is listed here:
>>
>> https://docs.djangoproject.com/en/dev/topics/email/#smtp-backend
>>
>> This section of the docs also shows you another option -- if, during
>> testing, you don't want to send mail out on the wire, you can
>> configure your server to use a different mail "backend" for sending
>> mail. So, for example, you can configure all mail to be "sent" to the
>> console, saving you the trouble of waiting for your mail client to
>> pick up mail from a mailbox.
>>
>> Yours,
>> Russ Magee %-)
>>
>> On Wed, Oct 17, 2012 at 8:28 PM, Larry Martell 
>> wrote:
>> > I'm trying to set up the password reset stuff, following what I read at:
>> >
>> >
>> > https://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-a-password-reset-feature
>> >
>> > When I click on the 'Reset my password' button, I get:
>> >
>> > SMTPServerDisconnected at /admin/password_reset/
>> > please run connect() first
>> >
>> >
>> > I do have postfix running on the same machine that apache is running
>> > on. Is there some part of the setup missing?
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Django users" group.
>> > To post to this group, send email to django-users@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



What's the difference between django.views.generic.ListView and django.views.generic.list_detail?

2012-11-20 Thread Dae_James
What's the difference between django.views.generic.*ListView* and 
django.views.generic.*list_detail*?

I think the two have same function. Only the usage of them are different. 
Why do both of them exist?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/8zaooZqziv8J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: how i do a update in django QuerySet like this: update table t set col_a = col_a + 2 where col_b = 1

2012-11-20 Thread peixinchen
thanks, it works

在 2012年11月20日星期二UTC+8下午11时09分23秒,Tom Evans写道:
>
> On Tue, Nov 20, 2012 at 1:00 PM, peixinchen > 
> wrote: 
> > how i do a update in django QuerySet like this: update table t set col_a 
> = 
> > col_a + 2 where col_b = 1, 
> > 
> > i could use filter take the place of "where clause", but how "set col_a 
> = 
> > col_a + 2" to being? 
> > 
>
> from django.db.models import F 
> Foo.objects.filter(col_b=1).update(col_a=F('col_a')+2) 
>
> https://docs.djangoproject.com/en/1.4/topics/db/queries/#query-expressions 
>
> Cheers 
>
> Tom 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/bYjIECs-32YJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: how to use get_queryset in my code

2012-11-20 Thread Nebros
Its not a problem of the version, my pycharm gave no error, but it was not 
possible to generate the model... by generating there was always an 
error, like it cant find an class or something else.
 

Am Dienstag, 20. November 2012 19:35:36 UTC+1 schrieb Martin J. Laubach:

> I tryed first this part with db models. but mssql doesnt work on it...
>>
>
>   BTW, why? I see there's a django-mssql, that should allow you to connect 
> to the database. Doesn't it work with your version? I've never tried it 
> though, I just googled around a bit...
>
>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ywIaA4jUvRwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.