A fun little Django project [Robert Steckroth]

2012-10-12 Thread Robert Steckroth
Hey Gang, I have got my project up on Bitbucket -->
https://bitbucket.org/surgemcgee/django_template3d
It is a fun Django Project with some nice features. It is simple to
get up in going and provides
some abstract Django/HTML concepts.

-- 
Bust0ut, Surgemcgee: Systems Engineer ---
surgemcgee.com
BudTVNetwork.com
RadioWeedShow.com
"Bringing entertainment to Unix"

-- 
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.



User can't edit model even after permissions are issued

2012-10-12 Thread Shawn H
I'm new to Django, and I'm using the admin site to manage my users.  I have 
one app installed, and it has one model.  I created a new user, issued that 
user add, change, and delete privileges (as app | model | privilege), but 
when I log on as that user, I get the "you don't have permission to edit 
anything" error.  The user is active and is staff, but no joy.  What might 
I be missing?

-- 
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/-/hMcooZ2z7_4J.
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.



User can't edit anything

2012-10-12 Thread Shawn H
I'm new to django, and using the admin site for user management.  I've 
created a new user, issued app | model | permission of add, change, and 
delete to this user for the app I've built, but when I logon as that user, 
I get the "you don't have permission to edit anything".  The user is active 
(obviously as I can logon as that user) and is staff, but the permissions 
don't seem to be working.  What might I be missing?  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/-/5zMO9ZPGel4J.
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: get_or_create gave IntegrityError: (1062, "Duplicate entry) error sometimes

2012-10-12 Thread Wei Wei
I am new to Django. But does the error message literally mean you have
duplicated records against your unique_together constriction?

On Sat, Oct 13, 2012 at 9:47 AM, Zheng Li  wrote:

> class AB(models.Model):
> a = models.ForeignKey(A)
> b = models.ForeignKey(B)
> c = models.IntegerField(default=0)
> d = models.FloatField(default=0)
> e = models.IntegerField(default=0)
> f = models.FloatField(default=0)
> class Meta:
> unique_together = (('a', 'b'),)
>
> I have a class like above.
> when I call get_or_create, sometimes IntegrityError: (1062, "Duplicate
> entry) error happens.
> a, _ = AB.objects.get_or_create(a=a, b=b)
>
> I really have googled and worked on it for a while, but still nothing.
> anyone can help?
> Thanks in advance.
>
> --
> 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.



get_or_create gave IntegrityError: (1062, "Duplicate entry) error sometimes

2012-10-12 Thread Zheng Li
class AB(models.Model):
a = models.ForeignKey(A)
b = models.ForeignKey(B)
c = models.IntegerField(default=0)
d = models.FloatField(default=0)
e = models.IntegerField(default=0)
f = models.FloatField(default=0)
class Meta:
unique_together = (('a', 'b'),)

I have a class like above.
when I call get_or_create, sometimes IntegrityError: (1062, "Duplicate entry) 
error happens.
a, _ = AB.objects.get_or_create(a=a, b=b)

I really have googled and worked on it for a while, but still nothing.
anyone can help?
Thanks in advance.

-- 
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: perfectionists... motto doesn't fit

2012-10-12 Thread Russell Keith-Magee
On Fri, Oct 12, 2012 at 11:03 PM, bobhaugen  wrote:
> On Friday, October 12, 2012 7:56:52 AM UTC-5, Russell Keith-Magee wrote:
>
> Russell (and Jacob),
>
> I really appreciate the way you moderate the forum. The civility and
> helpfulness of the community was one of the main reasons I picked Django a
> few years ago.

You're most welcome.

Yours,
Russ Magee %-)

-- 
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: Create table and load data

2012-10-12 Thread Kurtis Mullins
Whoops, sorry that was the master branch. Here you go:
https://github.com/django/django/blob/1.4.1/django/core/management/commands/syncdb.py

On Fri, Oct 12, 2012 at 4:24 PM, Kurtis Mullins wrote:

> Good luck to you! The code is here if you want to start crawling through
> it for a good point to place a breakpoint:
> https://github.com/django/django/blob/master/django/core/management/commands/syncdb.py
>
>
> On Fri, Oct 12, 2012 at 3:30 PM, Larry Martell wrote:
>
>> On Fri, Oct 12, 2012 at 12:22 PM, Kurtis Mullins
>>  wrote:
>> > On Fri, Oct 12, 2012 at 2:09 PM, Larry Martell > >
>> > wrote:
>> >>
>> >>
>> >> So my client decided to use xml. I created the file and put it in
>> >> fixtures/initial_data.xml. On my development machine, which is a Mac,
>> >> it worked fine - running syncdb loaded the data. But on my client's
>> >> machine, which is running CentOS, running syncdb did not load the data
>> >> (it said 'Installed 0 object(s) from 0 fixture(s)'). But when I ran:
>> >>
>> >> manage.py loaddata fixtures/initial_data.xml
>> >>
>> >> That worked. Anyone have any ideas why sycndb worked on my mashine,
>> >> but it's not working on theirs?
>> >
>> >
>> > That's very weird. I haven't seen that affect off-hand. I've worked with
>> > Django on Linux (CentOS, Ubuntu, Debian) as well as OSX and it has
>> always
>> > tended to work fine. I'm not sure on a solution other than to keep
>> checking
>> > for inconsistencies or issues with the .xml file itself. Hopefully
>> someone
>> > else who has ran into this problem before can chime in and offer some
>> help.
>> > Good luck!
>>
>> Yeah, I don't think it's platform dependent. The xml file was pulled
>> from our git repository, and it matches mine. And it works with
>> loaddata. I'll have to set a breakpoint and see why manage doesn't see
>> the file.
>>
>> --
>> 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.



Re: Create table and load data

2012-10-12 Thread Kurtis Mullins
Good luck to you! The code is here if you want to start crawling through it
for a good point to place a breakpoint:
https://github.com/django/django/blob/master/django/core/management/commands/syncdb.py

On Fri, Oct 12, 2012 at 3:30 PM, Larry Martell wrote:

> On Fri, Oct 12, 2012 at 12:22 PM, Kurtis Mullins
>  wrote:
> > On Fri, Oct 12, 2012 at 2:09 PM, Larry Martell 
> > wrote:
> >>
> >>
> >> So my client decided to use xml. I created the file and put it in
> >> fixtures/initial_data.xml. On my development machine, which is a Mac,
> >> it worked fine - running syncdb loaded the data. But on my client's
> >> machine, which is running CentOS, running syncdb did not load the data
> >> (it said 'Installed 0 object(s) from 0 fixture(s)'). But when I ran:
> >>
> >> manage.py loaddata fixtures/initial_data.xml
> >>
> >> That worked. Anyone have any ideas why sycndb worked on my mashine,
> >> but it's not working on theirs?
> >
> >
> > That's very weird. I haven't seen that affect off-hand. I've worked with
> > Django on Linux (CentOS, Ubuntu, Debian) as well as OSX and it has always
> > tended to work fine. I'm not sure on a solution other than to keep
> checking
> > for inconsistencies or issues with the .xml file itself. Hopefully
> someone
> > else who has ran into this problem before can chime in and offer some
> help.
> > Good luck!
>
> Yeah, I don't think it's platform dependent. The xml file was pulled
> from our git repository, and it matches mine. And it works with
> loaddata. I'll have to set a breakpoint and see why manage doesn't see
> the file.
>
> --
> 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.



Re: Create table and load data

2012-10-12 Thread Larry Martell
On Fri, Oct 12, 2012 at 12:22 PM, Kurtis Mullins
 wrote:
> On Fri, Oct 12, 2012 at 2:09 PM, Larry Martell 
> wrote:
>>
>>
>> So my client decided to use xml. I created the file and put it in
>> fixtures/initial_data.xml. On my development machine, which is a Mac,
>> it worked fine - running syncdb loaded the data. But on my client's
>> machine, which is running CentOS, running syncdb did not load the data
>> (it said 'Installed 0 object(s) from 0 fixture(s)'). But when I ran:
>>
>> manage.py loaddata fixtures/initial_data.xml
>>
>> That worked. Anyone have any ideas why sycndb worked on my mashine,
>> but it's not working on theirs?
>
>
> That's very weird. I haven't seen that affect off-hand. I've worked with
> Django on Linux (CentOS, Ubuntu, Debian) as well as OSX and it has always
> tended to work fine. I'm not sure on a solution other than to keep checking
> for inconsistencies or issues with the .xml file itself. Hopefully someone
> else who has ran into this problem before can chime in and offer some help.
> Good luck!

Yeah, I don't think it's platform dependent. The xml file was pulled
from our git repository, and it matches mine. And it works with
loaddata. I'll have to set a breakpoint and see why manage doesn't see
the file.

-- 
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: Create table and load data

2012-10-12 Thread Kurtis Mullins
On Fri, Oct 12, 2012 at 2:09 PM, Larry Martell wrote:
>
>
> So my client decided to use xml. I created the file and put it in
> fixtures/initial_data.xml. On my development machine, which is a Mac,
> it worked fine - running syncdb loaded the data. But on my client's
> machine, which is running CentOS, running syncdb did not load the data
> (it said 'Installed 0 object(s) from 0 fixture(s)'). But when I ran:
>
> manage.py loaddata fixtures/initial_data.xml
>
> That worked. Anyone have any ideas why sycndb worked on my mashine,
> but it's not working on theirs?


That's very weird. I haven't seen that affect off-hand. I've worked with
Django on Linux (CentOS, Ubuntu, Debian) as well as OSX and it has always
tended to work fine. I'm not sure on a solution other than to keep checking
for inconsistencies or issues with the .xml file itself. Hopefully someone
else who has ran into this problem before can chime in and offer some help.
Good luck!

-- 
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: Create table and load data

2012-10-12 Thread Larry Martell
On Thu, Oct 11, 2012 at 4:51 AM, Larry Martell  wrote:
> On Thu, Oct 11, 2012 at 1:37 AM, Joseph Wayodi  wrote:
>> On Thu, Oct 11, 2012 at 2:23 AM, Larry Martell  
>> wrote:
>>> I'm having trouble getting django to read my fixture file. I created it in 
>>> yaml:
>>>
>>> - model: cdsem.fields
>>>pk: 1
>>>fields:
>>>  name: data_file_id
>>>  description: data_file_id
>>> - model: cdsem.fields
>>>pk: 2
>>>fields:
>>>  name: tool_id
>>>  description: tool_id
>>>
>>> and so on.
>>>
>>> I put it in a file called initial_data.yaml in the fixtures dir of my
>>> app. When I run syncdb it does not pick it up. FIXTURE_DIRS was not
>>> set. I should not have to set it, but I did anyway, but it still did
>>> not pick up the file. If I run loaddata and give it the path to the
>>> file I get:
>>>
>>> Problem installing fixture './fixtures/initial_data': yaml is not a
>>> known serialization format.
>>>
>>> The docs say yaml is supported. What am I doing wrong?
>>>
>>
>> According to the docs [1], you may need to install PyYAML:
>> .
>>
>> [1] 
>> 
>
> Thanks! Didn't see that.

So my client decided to use xml. I created the file and put it in
fixtures/initial_data.xml. On my development machine, which is a Mac,
it worked fine - running syncdb loaded the data. But on my client's
machine, which is running CentOS, running syncdb did not load the data
(it said 'Installed 0 object(s) from 0 fixture(s)'). But when I ran:

manage.py loaddata fixtures/initial_data.xml

That worked. Anyone have any ideas why sycndb worked on my mashine,
but it's not working on theirs?

-- 
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 multi db routing doesnt work wich multiple schemas

2012-10-12 Thread Michał Nowotka
Anyway, look at the query that needs to be executed. This doesn't
contain any joins. The only problem is that this perfectly correct
query is send to wrong schema although the router suggests a good one.
I don't know why, is there anyone who can explain this to me?

-- 
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 multi db routing doesnt work wich multiple schemas

2012-10-12 Thread Michał Nowotka
Unfortunately not exactly.
Schema in Oracle is a synonym of user so you need name and password.
That's why it doesn't fit into tablespaces solution you pointed.
There is open ticket about support for multiple schemas but it's still
unfinished.

This is why I was looking for solution that would work now.
Having said that I really don't understand two things:

- why I was able to create two objects form different db connections
without any error but I can't do the opposite so retrieve related
object from original one?
- what's the purpose of allow_relation method in the router if despite
it suggestions I can bypass this limitation?

-- 
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 multi db routing doesnt work wich multiple schemas

2012-10-12 Thread Tomáš Ehrlich
Sorry, I've just found that schema != tablespace, so my last response is 
irelevant...

Cheers,
 Tom

Dne pátek, 12. října 2012 19:26:53 UTC+2 Tomáš Ehrlich napsal(a):
>
> Hi Michał, 
> is "schema" the same as thing as "tablespace"? If so, you should define 
> them using 
> db_tablespace meta keyword. 
> https://docs.djangoproject.com/en/1.4/topics/db/tablespaces/ 
>
> DATABASES creates new database connection and it's really not 
> possible to make relations between databases. 
>
> Cheers, 
>  Tom 
>
> Dne Fri, 12 Oct 2012 17:19:42 +0100 
> Michał Nowotka  napsal(a): 
>
> > First of all the error is not from django but from database. 
> > Secondly I'm not using different databases but different schemas so 
> > relations are possible. 
> > The error has nothing to do with foreign key or any relation. 
> > It just looks like django is ignoring router suggestion and directs 
> > sql query to wrong DB. 
> > 
>
>
>
> S pozdravem 
>   Tomáš Ehrlich 
>
> Email:  tomas.ehrl...@gmail.com 
> Tel:+420 608 219 889 
> Jabber: elv...@jabber.cz 
>
> "Půjdu kamkoliv, pokud je to kupředu." - J. London 
>

-- 
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/-/SjxuNuNqF78J.
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 multi db routing doesnt work wich multiple schemas

2012-10-12 Thread Tomas Ehrlich
Hi Michał,
is "schema" the same as thing as "tablespace"? If so, you should define them 
using
db_tablespace meta keyword.
https://docs.djangoproject.com/en/1.4/topics/db/tablespaces/

DATABASES creates new database connection and it's really not
possible to make relations between databases.

Cheers,
 Tom

Dne Fri, 12 Oct 2012 17:19:42 +0100
Michał Nowotka  napsal(a):

> First of all the error is not from django but from database.
> Secondly I'm not using different databases but different schemas so
> relations are possible.
> The error has nothing to do with foreign key or any relation.
> It just looks like django is ignoring router suggestion and directs
> sql query to wrong DB.
> 



S pozdravem
  Tomáš Ehrlich

Email:  tomas.ehrl...@gmail.com
Tel:+420 608 219 889
Jabber: elv...@jabber.cz

"Půjdu kamkoliv, pokud je to kupředu." - J. London

-- 
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: Unhandled exception during validation

2012-10-12 Thread Tomas Ehrlich
Well, in this case, I don't see problem in erroritself  (that happens).
I see problem in missing trackback (that's not usual). My assuption was
that "something" suppress it (don't know if it's possible, but I
assume it is).

Cheers,
 Tom

Dne Fri, 12 Oct 2012 17:00:01 +0100
Tom Evans  napsal(a):

> On Fri, Oct 12, 2012 at 4:45 PM, Tomáš Ehrlich  
> wrote:
> > Hello Oyvind,
> > that's weird, Django (or Python  in general) usually provide very long and
> > descriptive trackback.
> >
> > Could you please provide more information? What version of Python do you
> > have? Does it fail when you run ./manage.py runserver? You've mentioned, the
> > error is in local app, does that app load any thirdparty modules?
> >
> > I've never came across unhandled exception which doesn't show trackback, so
> > my guess is some c/c++ python extension (PIL, psycopg2, …). But that's just
> > guess…
> >
> > Cheers,
> >  Tom
> 
> I think you've misunderstood the OP, the error occurs in Django's
> AppCache, which is populated when you start django in any manner (even
> going to the shell). The error occurs when AppCache tries to load one
> of his custom apps, and the issue is that the error message does not
> indicate the error that occurred, provide a proper traceback or even
> indicate which app it failed to load.
> 
> (Sorry OP, haven't a clue)
> 
> Cheers
> 
> Tom
> 



S pozdravem
  Tomáš Ehrlich

Email:  tomas.ehrl...@gmail.com
Tel:+420 608 219 889
Jabber: elv...@jabber.cz

"Půjdu kamkoliv, pokud je to kupředu." - J. London

-- 
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 multi db routing doesnt work wich multiple schemas

2012-10-12 Thread Michał Nowotka
First of all the error is not from django but from database.
Secondly I'm not using different databases but different schemas so
relations are possible.
The error has nothing to do with foreign key or any relation.
It just looks like django is ignoring router suggestion and directs
sql query to wrong DB.

-- 
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 multi db routing doesnt work wich multiple schemas

2012-10-12 Thread Tom Evans
On Fri, Oct 12, 2012 at 4:54 PM, mnowotka  wrote:
> I have django running on oracle backend. I need to use two schemas - one for
> a legacy DB, second one for all django related tables.
>
> So this is my settings.DATABASES:
>
> DATABASES = {
>
> 'default' : {
> 'ENGINE': 'django.db.backends.oracle'
> 'NAME': 'django',
> 'USER': 'django-tables',
> 'PASSWORD': '',
> 'HOST': 'localhost',
> 'PORT': '1531',
> },
>
> APPS_DB : {
> 'ENGINE': 'django.db.backends.oracle',
> 'NAME': 'django',
> 'USER': 'legacy-stuff',
> 'PASSWORD': '',
> 'HOST': 'localhost',
> 'PORT': '1531',
>  },
> }
>
> I also defined router:
>
> class MyRouter(object):
> """A router to control all database operations on models"""
>
> def __init__(self):
> aux = []
> for app in settings.INSTALLED_APPS:
> if not app.endswith('myapp'):
> aux.append(app)
> self.djangoStuff = tuple(map(lambda x: x[x.rfind('.')+1:], aux))
>
> def is_django_stuff(self, model):
> return model._meta.app_label in self.djangoStuff
>
> def db_for_read(self, model, **hints):
> "Point all django apps models to separate DB"
> logger.info("READ from " + model._meta.app_label)
> if self.is_django_stuff(model):
> logger.info("Will be directed to default DB")
> return None
> logger.info("Will be directed to legacy DB")
> return settings.APPS_DB
>
> def db_for_write(self, model, **hints):
> "Point all django apps models to separate DB"
> logger.info("WRITE")
> if self.is_django_stuff(model):
> return None
> return settings.APPS_DB
>
> def allow_relation(self, obj1, obj2, **hints):
> "Allow any relation"
> logger.info("ALLOW REL")
> return True
>
> def allow_syncdb(self, db, model):
> "Allow syncdb for all managed objects"
> logger.info("ALLOW SYNC")
> if db == 'default' and self.is_django_stuff(model):
> return True
> if db != 'default' and not self.is_django_stuff(model):
> return True
> return False
>
> Now I have very simple model:
>
> class Poll(models.Model):
> question = models.CharField(max_length=200)
> user = models.ForeignKey(User)
> pub_date = models.DateTimeField('date published')
>
> I make two syncdbs:
>
> python manage.py syncdb
> python manage.py syndb --database apps
>
> Everything goes fine. Then I create poll object using 'python manage.py
> shell'
>
> superuser = User.objects.all()[0]
> p = Poll(question="foo", user = superuser, pub_date = datetime.now())
> p.save()
>
> And I try to retrieve user from poll:
>
>   a = Poll.objects.all()
>   b = len(a)
>   b = a[0]
>   c = b.artist

You can't have relationships between models stored in different databases.

What happens when you define such an invalid relationship and follow
it, Django will use the database specified in b._state.db, and not
what the router determines.

It is an impossibility to have relationships that span different
databases - ie, this is not a Django limitation -  so this is just
describing what would happen when you attempt to do something invalid.

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.



django multi db routing doesnt work wich multiple schemas

2012-10-12 Thread mnowotka
 

I have django running on oracle backend. I need to use two schemas - one 
for a legacy DB, second one for all django related tables.

So this is my settings.DATABASES:

DATABASES = {

'default' : { 
'ENGINE': 'django.db.backends.oracle'
'NAME': 'django',  
'USER': 'django-tables',  
'PASSWORD': '',  
'HOST': 'localhost',   
'PORT': '1531', 
},

APPS_DB : { 
'ENGINE': 'django.db.backends.oracle', 
'NAME': 'django',  
'USER': 'legacy-stuff',  
'PASSWORD': '', 
'HOST': 'localhost', 
'PORT': '1531',  
 },
}

I also defined router:

class MyRouter(object):
"""A router to control all database operations on models"""

def __init__(self):
aux = []
for app in settings.INSTALLED_APPS:
if not app.endswith('myapp'):
aux.append(app)
self.djangoStuff = tuple(map(lambda x: x[x.rfind('.')+1:], aux))

def is_django_stuff(self, model):
return model._meta.app_label in self.djangoStuff

def db_for_read(self, model, **hints):
"Point all django apps models to separate DB"
logger.info("READ from " + model._meta.app_label)
if self.is_django_stuff(model):
logger.info("Will be directed to default DB")
return None
logger.info("Will be directed to legacy DB")
return settings.APPS_DB

def db_for_write(self, model, **hints):
"Point all django apps models to separate DB"
logger.info("WRITE")
if self.is_django_stuff(model):
return None
return settings.APPS_DB

def allow_relation(self, obj1, obj2, **hints):
"Allow any relation"
logger.info("ALLOW REL")
return True

def allow_syncdb(self, db, model):
"Allow syncdb for all managed objects"
logger.info("ALLOW SYNC")
if db == 'default' and self.is_django_stuff(model):
return True
if db != 'default' and not self.is_django_stuff(model):
return True
return False

Now I have very simple model:

class Poll(models.Model):
question = models.CharField(max_length=200)
user = models.ForeignKey(User)
pub_date = models.DateTimeField('date published')

I make two syncdbs:

python manage.py syncdb
python manage.py syndb --database apps

Everything goes fine. Then I create poll object using 'python manage.py 
shell'

superuser = User.objects.all()[0]
p = Poll(question="foo", user = superuser, pub_date = datetime.now())
p.save()

And I try to retrieve user from poll:

  a = Poll.objects.all()
  b = len(a)
  b = a[0]
  c = b.artist

I have logging enabled in router so I see that last query will be directed 
to correct DB:

READ from myapp
Will be directed to apps DB
READ from myapp
Will be directed to apps DB
READ from auth
Will be directed to default DB

I can even see actual SQL statement:

(0.005) SELECT "AUTH_USER"."ID", "AUTH_USER"."USERNAME", 
"AUTH_USER"."FIRST_NAME","AUTH_USER"."LAST_NAME", "AUTH_USER"."EMAIL", 
"AUTH_USER"."PASSWORD", "AUTH_USER"."IS_STAFF", "AUTH_USER"."IS_ACTIVE", 
"AUTH_USER"."IS_SUPERUSER", "AUTH_USER"."LAST_LOGIN", "AUTH_USER"."DATE_JOINED" 
FROM "AUTH_USER" WHERE "AUTH_USER"."ID" = :arg0 ; args=(1,)

But I'm getting error:

  File "", line 1, in 
  File 
"/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/db/models/fields/related.py",
 line 350, in __get__
rel_obj = qs.get(**params)
  File 
"/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/db/models/query.py",
 line 361, in get
num = len(clone)
  File 
"/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/db/models/query.py",
 line 85, in __len__
self._result_cache = list(self.iterator())
  File 
"/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/db/models/query.py",
 line 291, in iterator
for row in compiler.results_iter():
  File 
"/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/db/models/sql/compiler.py",
 line 763, in results_iter
for rows in self.execute_sql(MULTI):
  File 
"/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/db/models/sql/compiler.py",
 line 818, in execute_sql
cursor.execute(sql, params)
  File 
"/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/db/backends/util.py",
 line 40, in execute
return self.cursor.execute(sql, params)
  File 
"/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/db/backends/oracle/base.py",
 line 675, in execute
return self.cursor.execute(query, self._param_generator(params))
DatabaseError: ORA-00942: table or view does not exist

So my question is - what am I doing wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 

Re: Unhandled exception during validation

2012-10-12 Thread Tom Evans
On Fri, Oct 12, 2012 at 4:45 PM, Tomáš Ehrlich  wrote:
> Hello Oyvind,
> that's weird, Django (or Python  in general) usually provide very long and
> descriptive trackback.
>
> Could you please provide more information? What version of Python do you
> have? Does it fail when you run ./manage.py runserver? You've mentioned, the
> error is in local app, does that app load any thirdparty modules?
>
> I've never came across unhandled exception which doesn't show trackback, so
> my guess is some c/c++ python extension (PIL, psycopg2, …). But that's just
> guess…
>
> Cheers,
>  Tom

I think you've misunderstood the OP, the error occurs in Django's
AppCache, which is populated when you start django in any manner (even
going to the shell). The error occurs when AppCache tries to load one
of his custom apps, and the issue is that the error message does not
indicate the error that occurred, provide a proper traceback or even
indicate which app it failed to load.

(Sorry OP, haven't a clue)

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: Unhandled exception during validation

2012-10-12 Thread Tomáš Ehrlich
Hello Oyvind,
that's weird, Django (or Python  in general) usually provide very long and 
descriptive trackback.

Could you please provide more information? What version of Python do you 
have? Does it fail when you run ./manage.py runserver? You've mentioned, 
the error is in local app, does that app load any thirdparty modules?

I've never came across unhandled exception which doesn't show trackback, so 
my guess is some c/c++ python extension (PIL, psycopg2, …). But that's just 
guess…

Cheers,
 Tom

Dne pátek, 12. října 2012 12:47:51 UTC+2 Oyvind Idland napsal(a):
>
> Hello,
>
> I am currently trying to upgrade a site from 1.2.x to 1.4.1. When I try to 
> start the app, I get this:
>
> Validating models...
> Unhandled exception in thread started by <__main__.NewThreadStartup 
> instance at 0x03D13738>
>
>
> Since the output is very economical about info, I spent some time to track 
> down the origins. 
> I found this in loading.py,  AppCache._populate():
>
> for app_name in settings.INSTALLED_APPS:
> if app_name in self.handled:
> continue
> self.load_app(app_name, True)< CRASH
>
> The app it tries to load, is a local one (made by a co-developer some time 
> ago). 
>
> Shouldn't there be better error handling in cases like this, at least 
> showing what happened, and where ?
> There is no exception handling what so ever..
>
> -- Oyvind
>
>
>

-- 
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/-/SbzMIfmJbZEJ.
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: "Writing your first Django app" Tutorial Question

2012-10-12 Thread Tomáš Ehrlich
Hi Stefano,
your understanding is incorrect. Django (neither Python) doesn't load (or 
import) anything by himself. Everything what you import is everything what 
you get. There are few exceptions, like Python builtin module (and default 
tags/templates in Django templates), but that's definitely not this case.

Template context consist of:
 - your context dictionary (in this case {'poll': p})
 - dictionaries of all context processors (if you use RequestContext)
 - and default tags/filters

One don't have to load Choice class, because choice instances are returned 
with {% for choice in poll.choice_set.all %}. You can access Choice class 
in choice.__class__ if you want, but that's unnecessary in most cases (in 
templates).

I'm writing this because recently I've been working with PHP and Yii 
framework and that kind of autoloading, you've mentioned, *does* occur 
there. It doesn't work like that in Python (and Django doesn't add it).

Cheers,
 Tom

Dne pátek, 12. října 2012 14:12:10 UTC+2 Stefano Tranquillini napsal(a):
>
> Not an expert at all, but this is my understanding.
> In the view you only set up data that will be available in the template, 
> there's no relation between the imports there and what can be displayed in 
> the template. 
> the templates probably loads the classes when he need to display something.
> not sure.
>
>  
>
> On Fri, Oct 12, 2012 at 12:06 PM, Rick Chong  > wrote:
>
>> Hi, I have just started learning programming and I am following the 
>> creating a poll app tutorial at:
>> https://docs.djangoproject.com/en/1.4/intro/tutorial03/
>>
>> I hope that someone has attempted this tutorial and is able to help me on 
>> some very beginner questions:
>>
>> In this app, we defined 2 classes in the model - Poll & Choice:
>>
>>> import datetime
>>>
>>> from django.utils import timezone
>>>
>>> from django.db import models
>>>
>>>   
>>>
>>> # Create your models here.
>>>
>>> class Poll(models.Model):
>>>
>>>  question = models.CharField(max_length=200)
>>>
>>>  pub_date = models.DateTimeField('date published')
>>>
>>>  def __unicode__(self):
>>>
>>>  return self.question
>>>
>>>  def was_published_recently(self):
>>>
>>>  return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
>>>
>>>  was_published_recently.admin_order_field = 'pub_date'
>>>
>>>  was_published_recently.boolean = True
>>>
>>>  was_published_recently.short_description = 'Published recently?'
>>>
>>>
 class Choice(models.Model):
>>>
>>>  poll = models.ForeignKey(Poll)
>>>
>>>  choice = models.CharField(max_length=200)
>>>
>>>  votes = models.IntegerField()
>>>
>>>  def __unicode__(self):
>>>
>>>  return self.choice
>>>
>>>  
>>
>> Then in views.py... I have the following code:
>>
>>> from django.shortcuts import render_to_response, get_object_or_404
>>>
>>> from polls.models import Poll
>>>
>>>
 def detail(request, poll_id):
>>>
>>> p = get_object_or_404(Poll, pk=poll_id)
>>>
>>>  return render_to_response('polls/detail.html', {'poll': p})
>>>
>>>
>>>
>>
>> Then in my template, detail.html. I have the following code:
>>
>>> {{ poll.question }}
>>>
>>> 
>>>
>>> {% for choice in poll.choice_set.all %}
>>>
>>>  {{ choice.choice }}
>>>
>>> {% endfor %}
>>>
>>> 
>>>
>>>
>>
>>  
>> The scripts run My question:
>> In views.py, I only import Poll class from model... why am I able to 
>> display choice, which is a variable under Choice class?
>>
>>
>> Thank you very much.
>>
>>
>>
>>
>> Rick
>>
>> -- 
>> 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/-/2vqJuWiYVuIJ.
>> 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.
>>
>
>
>
> -- 
> Stefano
>  

-- 
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/-/SDIG4V7RbnwJ.
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: perfectionists... motto doesn't fit

2012-10-12 Thread bobhaugen
On Friday, October 12, 2012 7:56:52 AM UTC-5, Russell Keith-Magee wrote:

> The reason I jumped on this was pre-emptive. We've had two threads on 
> Django-dev in a week, started by the same OP, which have quickly 
> degraded into *very* ugly territory. As Jacob has commented on the 
> other threads, we're taking it on faith that the OP has good 
> intentions but has phrased himself badly, but he, and others, have 
> been warned about keeping a civil tongue. Given that a discussion of 
> "what defines a perfectionist" is in no way on-topic for django-users, 
> and has all sorts of potential to end up in bad places, I have no 
> problem asking people to step away from this particular topic. 
>

Russell (and Jacob), 

I really appreciate the way you moderate the forum. The civility and 
helpfulness of the community was one of the main reasons I picked Django a 
few years ago.

Thanks again,
Bob Haugen

>  
>

-- 
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/-/tqU9hth-SaIJ.
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: Image/Photo app

2012-10-12 Thread Javier Guerra Giraldez
On Fri, Oct 12, 2012 at 9:41 AM, Kurtis Mullins
 wrote:
> I'm not sure about the syncing of tags between the GUI and Web Application;
> I think that would completely depend on your ability to export or otherwise
> use the tags created by the GUI application. If you can figure out how to
> get ahold of that data and parse it, then I'm sure it wouldn't be too
> difficult to re-use it.

Digikam stores all metadata in both the images themselves (in several
of EXIF, IPTC, XMP, etc) and in a SQL database, either SQLite or
MySQL.

the best would be to directly read that database from your web app; or
to make the 'synchronize' step just read from one database to the
other.

unfortunately, it seems Digikam doesn't store thumbnails anywhere, so
you'll have to handle that yourself.

-- 
Javier

-- 
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: Image/Photo app

2012-10-12 Thread Kurtis Mullins
Hey Thomas,

I'm not sure if you're on a deadline or what-not; but these are usually the
kinds of apps I develop (personally) for fun. For example, you can extend
your code-base to scan the images to pull in its EXIF data and what-not.

If you're on a deadline, there's multiple Django Applications you could
probably tie together to get decent results relatively quickly. Django
Tags, Haystack (for search), and maybe Django Guardian for the permissions
(although I like going custom here). Thumbnails might also be helpful.

One thing I would recommend is writing a Django Management "Script" to scan
your library and synchronize it instead of relying on the built-in "File
Upload Handlers" since you've already got the files on your disk and it
would be insanely inefficient to Upload Them One by One to you own server
(I doubt that was your idea, though).

I'm not sure about the syncing of tags between the GUI and Web Application;
I think that would completely depend on your ability to export or otherwise
use the tags created by the GUI application. If you can figure out how to
get ahold of that data and parse it, then I'm sure it wouldn't be too
difficult to re-use it.

Good luck!

On Fri, Oct 12, 2012 at 10:32 AM, Thomas Guettler  wrote:

> I have 40k photos (jpg) on my ubuntu PC and want to share them with my
> friends and
> family.
>
> I searched for a django app which can sync with a local application like
> digikam or shotwell. But none
> seem to be alive.
>
> Which django app do you use for photos?
>
> It would be great, if I could sync tags and notes between the GUI and the
> web app.
>
> I need these features:
>  - tags
>  - notes
>  - star rating
>  - access control: A user must only see these pictures which match to his
> groups/permissions.
>  - search by tag and date.
>
>
> Regards,
>   Thomas Güttler
>
>
>
>
> --
> Thomas Guettler, http://www.thomas-guettler.de/
> E-Mail: guettli (*) thomas-guettler + 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+unsubscribe@**
> 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.



Image/Photo app

2012-10-12 Thread Thomas Guettler

I have 40k photos (jpg) on my ubuntu PC and want to share them with my friends 
and
family.

I searched for a django app which can sync with a local application like 
digikam or shotwell. But none
seem to be alive.

Which django app do you use for photos?

It would be great, if I could sync tags and notes between the GUI and the web 
app.

I need these features:
 - tags
 - notes
 - star rating
 - access control: A user must only see these pictures which match to his 
groups/permissions.
 - search by tag and date.


Regards,
  Thomas Güttler




--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + 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: perfectionists... motto doesn't fit

2012-10-12 Thread Cal Leeming [Simplicity Media Ltd]
On Fri, Oct 12, 2012 at 1:55 PM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:

> On Fri, Oct 12, 2012 at 7:47 PM, Cal Leeming [Simplicity Media Ltd]
>  wrote:
> >
> >
> > On Fri, Oct 12, 2012 at 3:33 AM, Russell Keith-Magee
> >  wrote:
> >>
> >> On Fri, Oct 12, 2012 at 9:00 AM, Cal Leeming [Simplicity Media Ltd]
> >>  wrote:
> >> > Lets say you if you were given 1 day to build a shed..
> >> >
> >> > PHP = build your own hammer/screwdriver from scratch, and then use
> those
> >> > to
> >> > build your shed - all within the same timeframe
> >> > PHP with Zend Framework = the equivalent of trying to build your shed
> >> > with
> >> > your childs "early learning toolset", using blu-tac for glue.
> >> > Django = build the shed with the right tools, equipment and materials
> as
> >> > your disposal.
> >>
> >> Ok - lets back away from this thread right now.
> >>
> >> There's absolutely no benefit to be gained in continuing a thread
> >> whose sole purpose is to debate the merits of a *tagline*.
> >
> >
> > Personally I interpreted it as an interesting topic on what really
> defines a
> > perfectionist.. although it doesn't seem to have been perceived this way,
> > which is sad.
>
> > The OP was happy with the "how you got there" thought - it was a simple
> > question with a simple answer...
> >
> > I don't know why this thread has been overreacted to :X
>
> The reason I jumped on this was pre-emptive. We've had two threads on
> Django-dev in a week, started by the same OP, which have quickly
> degraded into *very* ugly territory. As Jacob has commented on the
> other threads, we're taking it on faith that the OP has good
> intentions but has phrased himself badly, but he, and others, have
> been warned about keeping a civil tongue. Given that a discussion of
> "what defines a perfectionist" is in no way on-topic for django-users,
> and has all sorts of potential to end up in bad places, I have no
> problem asking people to step away from this particular topic.
>

Sorry, I wasn't aware of the background behind this, and makes total sense
now. My apologies.


>
> Yours,
> Russ Magee %-)
>
> --
> 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.



Re: Facebook like button in django

2012-10-12 Thread Tomas Neme
> I want to create a website facebook like, but real simple and I want to have
> a button that I can give to blogger to add them on their blog entries.  It
> have nothing to do with facebook.

Ah! so you want your own "facebook button"!

It'll be mostly a javascript task, rather than django-specific. In
order to protect your users' identities, you won't be giving the
client (blog) an actual HTML form, but rather (like the FB button) a
link to a JS library, and some markup that the library will use to
create an iframe to your website where you'll send the actual rendered
markup

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: Facebook like button in django

2012-10-12 Thread David Gomez
I want to create a website facebook like, but real simple and I want to 
have a button that I can give to blogger to add them on their blog entries. 
 It have nothing to do with facebook.

On Friday, October 12, 2012 9:03:26 AM UTC-4, David Gomez wrote:
>
> No the button is for my own website. 
>
> On Friday, October 12, 2012 12:41:30 AM UTC-4, Matteo Suppo wrote:
>>
>> You want to add a Facebook share button that lets people share things on 
>> Facebook but also save what they are sharing on your database?
>>
>> On Thursday, October 11, 2012 9:50:54 PM UTC+2, David Gomez wrote:
>>>
>>> How can I create a Facebook Share button in django? I would like 
>>> something like this:
>>> button name my_website
>>> When user click the button it would pop up a window with a form
>>> When user click the button, it will grab the form information and the 
>>> information on the blog, and put it on the database like it would do on a 
>>> regular form. 
>>> The form will have:
>>> username = username
>>> password = password
>>> note = what ever note the user type
>>> blog = the blog where the button was in.
>>>
>>> Thanks in advance
>>>
>>

-- 
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/-/zaUm3qJEw9EJ.
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: "Writing your first Django app" Tutorial Question

2012-10-12 Thread Jan Bednařík
Hi,

model Choice is related to model Poll by ForeignKey. All Choice
objects related to specific Poll object can by returned by:

my_poll.choice_set.all()

And that is happening in the template in for loop:

{% for choice in poll.choice_set.all %}
...

More detailed info is here:
https://docs.djangoproject.com/en/1.4/topics/db/queries/#backwards-related-objects

Honza


On Fri, Oct 12, 2012 at 12:06 PM, Rick Chong  wrote:
> Hi, I have just started learning programming and I am following the creating
> a poll app tutorial at:
> https://docs.djangoproject.com/en/1.4/intro/tutorial03/
>
> I hope that someone has attempted this tutorial and is able to help me on
> some very beginner questions:
>
> In this app, we defined 2 classes in the model - Poll & Choice:
>>>
>>> import datetime
>>>
>>> from django.utils import timezone
>>>
>>> from django.db import models
>>>
>>>
>>>
>>> # Create your models here.
>>>
>>> class Poll(models.Model):
>>>
>>> question = models.CharField(max_length=200)
>>>
>>> pub_date = models.DateTimeField('date published')
>>>
>>> def __unicode__(self):
>>>
>>> return self.question
>>>
>>> def was_published_recently(self):
>>>
>>> return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
>>>
>>> was_published_recently.admin_order_field = 'pub_date'
>>>
>>> was_published_recently.boolean = True
>>>
>>> was_published_recently.short_description = 'Published recently?'
>>>
>>>
>>> class Choice(models.Model):
>>>
>>> poll = models.ForeignKey(Poll)
>>>
>>> choice = models.CharField(max_length=200)
>>>
>>> votes = models.IntegerField()
>>>
>>> def __unicode__(self):
>>>
>>> return self.choice
>
>
>
> Then in views.py... I have the following code:
>>>
>>> from django.shortcuts import render_to_response, get_object_or_404
>>>
>>> from polls.models import Poll
>>>
>>>
>>> def detail(request, poll_id):
>>>
>>> p = get_object_or_404(Poll, pk=poll_id)
>>>
>>> return render_to_response('polls/detail.html', {'poll': p})
>>
>>
>
>
> Then in my template, detail.html. I have the following code:
>>>
>>> {{ poll.question }}
>>>
>>> 
>>>
>>> {% for choice in poll.choice_set.all %}
>>>
>>> {{ choice.choice }}
>>>
>>> {% endfor %}
>>>
>>> 
>
>
>
>
> The scripts run My question:
> In views.py, I only import Poll class from model... why am I able to display
> choice, which is a variable under Choice class?
>
>
> Thank you very much.
>
>
>
>
> Rick
>
> --
> 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/-/2vqJuWiYVuIJ.
> 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: Facebook like button in django

2012-10-12 Thread David Gomez
No the button is for my own website. 

On Friday, October 12, 2012 12:41:30 AM UTC-4, Matteo Suppo wrote:
>
> You want to add a Facebook share button that lets people share things on 
> Facebook but also save what they are sharing on your database?
>
> On Thursday, October 11, 2012 9:50:54 PM UTC+2, David Gomez wrote:
>>
>> How can I create a Facebook Share button in django? I would like 
>> something like this:
>> button name my_website
>> When user click the button it would pop up a window with a form
>> When user click the button, it will grab the form information and the 
>> information on the blog, and put it on the database like it would do on a 
>> regular form. 
>> The form will have:
>> username = username
>> password = password
>> note = what ever note the user type
>> blog = the blog where the button was in.
>>
>> Thanks in advance
>>
>

-- 
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/-/I-GlNA7HqAAJ.
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: Social networking site

2012-10-12 Thread Manu S Ajith
if you are looking a ready made solution I suggest using ELGG - which is
not Django by the way but a working solution in PHP or Dolphin.

On Fri, Oct 12, 2012 at 2:23 PM, tojo cherian  wrote:

> Hi,
> please help me to model a social networking site which has chats,
> debates, polls, petitions, etc
>
> It would be helpful if anyone can post some link which would help in
> developing a social networking site.
>
> Cheers
> Tojo
>
> --
> 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/-/kpImIxg_ZvsJ.
> 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.
>



-- 

Manu S Ajith
Program Lead,
Ruby Kitchen Technosol Pvt. Ltd.,
Cochin - 682309.
http://rubykitchen.in | m...@rubykitchen.org
(O) 0484 2114850  | (M) +91 9447-786-299

-
I don't like the idea that I'm not in control of my life.
[The Matrix]

-- 
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: "Writing your first Django app" Tutorial Question

2012-10-12 Thread Jason Sibre
Hi Rick,
I'll try to explain, but it's really more about Python than Django...

(I'm not familiar with the tutorial app, so I'm basing my answers on what code 
you copied into your email.)

That import of Poll that you see in details.py doesn't even enter into it.  
It's only used on the line that says "p = get_object_or_404(...".  In fact (and 
here's where my newness in Django shows), I don't think that Poll is even 
visible (in scope) in the detail.html template.  But the Poll instance that was 
put passed to "render_to_response(..." is.  The "p" variable had an instance of 
a Poll, and it was bound to the name 'poll' in that bit "{'poll':p}".

Once in the template, it's just a matter of traversing the objects.  
poll.choice_set.all presumably returns a set (or list?) of Choice instances, 
which are bound to the variable "choice".  Then, it's just a matter resolving 
the "choice" name on that instance.  

Since Python is a dynamically typed language, so you don't need to declare the 
data type of "choice" before assigning values to it, so there's no need to do 
something like 
Choice choice = null
which you might need to do in a language like Java.  If you *did* need to do 
that, you'd have to import Choice so that the above line would work.  Since you 
*don't* need to do that, and you're never referencing "Choice" in the template, 
there's no need to import it. 

Maybe it would help to think of import as a special kind of assignment operator 
(that's a gross simplification, but it may help as a metaphor)...  Writing 
from polls.models import Choice
is a bit similar in concept to saying something like
Choice = polls.models.Choice   #make a local reference the Choice class in the 
polls.models package.

Does that help at all?  
This is all way more related to basic Python than to Django, and you may find 
it helpful to run through a Python tutorial (http://docs.python.org/tutorial/ 
for example)

Jason


On Oct 12, 2012, at 5:06 AM, Rick Chong wrote:

> Hi, I have just started learning programming and I am following the creating 
> a poll app tutorial at:
> https://docs.djangoproject.com/en/1.4/intro/tutorial03/
> 
> I hope that someone has attempted this tutorial and is able to help me on 
> some very beginner questions:
> 
> In this app, we defined 2 classes in the model - Poll & Choice:
> import datetime
> from django.utils import timezone
> from django.db import models
>   
> # Create your models here.
> class Poll(models.Model):
>   question = models.CharField(max_length=200)
>   pub_date = models.DateTimeField('date published')
>   def __unicode__(self):
>   return self.question
>   def was_published_recently(self):
>   return self.pub_date >= timezone.now() - 
> datetime.timedelta(days=1)
>   was_published_recently.admin_order_field = 'pub_date'
>   was_published_recently.boolean = True
>   was_published_recently.short_description = 'Published recently?'
> 
> class Choice(models.Model):
>   poll = models.ForeignKey(Poll)
>   choice = models.CharField(max_length=200)
>   votes = models.IntegerField()
>   def __unicode__(self):
>   return self.choice
>  
> 
> Then in views.py... I have the following code:
> from django.shortcuts import render_to_response, get_object_or_404
> from polls.models import Poll
> 
> def detail(request, poll_id):
>   p = get_object_or_404(Poll, pk=poll_id)
>   return render_to_response('polls/detail.html', {'poll': p})
> 
> 
> 
> Then in my template, detail.html. I have the following code:
> {{ poll.question }}
> 
> {% for choice in poll.choice_set.all %}
>   {{ choice.choice }}
> {% endfor %}
> 
> 
> 
>  
> The scripts run My question:
> In views.py, I only import Poll class from model... why am I able to display 
> choice, which is a variable under Choice class?
> 
> 
> Thank you very much.
> 
> 
> 
> 
> Rick
> 
> -- 
> 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/-/2vqJuWiYVuIJ.
> 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: perfectionists... motto doesn't fit

2012-10-12 Thread Russell Keith-Magee
On Fri, Oct 12, 2012 at 7:47 PM, Cal Leeming [Simplicity Media Ltd]
 wrote:
>
>
> On Fri, Oct 12, 2012 at 3:33 AM, Russell Keith-Magee
>  wrote:
>>
>> On Fri, Oct 12, 2012 at 9:00 AM, Cal Leeming [Simplicity Media Ltd]
>>  wrote:
>> > Lets say you if you were given 1 day to build a shed..
>> >
>> > PHP = build your own hammer/screwdriver from scratch, and then use those
>> > to
>> > build your shed - all within the same timeframe
>> > PHP with Zend Framework = the equivalent of trying to build your shed
>> > with
>> > your childs "early learning toolset", using blu-tac for glue.
>> > Django = build the shed with the right tools, equipment and materials as
>> > your disposal.
>>
>> Ok - lets back away from this thread right now.
>>
>> There's absolutely no benefit to be gained in continuing a thread
>> whose sole purpose is to debate the merits of a *tagline*.
>
>
> Personally I interpreted it as an interesting topic on what really defines a
> perfectionist.. although it doesn't seem to have been perceived this way,
> which is sad.

> The OP was happy with the "how you got there" thought - it was a simple
> question with a simple answer...
>
> I don't know why this thread has been overreacted to :X

The reason I jumped on this was pre-emptive. We've had two threads on
Django-dev in a week, started by the same OP, which have quickly
degraded into *very* ugly territory. As Jacob has commented on the
other threads, we're taking it on faith that the OP has good
intentions but has phrased himself badly, but he, and others, have
been warned about keeping a civil tongue. Given that a discussion of
"what defines a perfectionist" is in no way on-topic for django-users,
and has all sorts of potential to end up in bad places, I have no
problem asking people to step away from this particular topic.

Yours,
Russ Magee %-)

-- 
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: Create table and load data

2012-10-12 Thread Larry Martell
On Fri, Oct 12, 2012 at 3:44 AM,   wrote:
> Hi Larry,
> Do you have PyYAML installed? If not install it first and retry or 
> alternatively you could just serialize your fixture in (my personal favorite) 
> JSON.

The client decide to use XML.

-- 
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: Create table and load data

2012-10-12 Thread bb6xt
Hi Larry,
Do you have PyYAML installed? If not install it first and retry or 
alternatively you could just serialize your fixture in (my personal favorite) 
JSON.
Cheers!
Abraham.

--
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.



Social networking site

2012-10-12 Thread tojo cherian
Hi,
please help me to model a social networking site which has chats, 
debates, polls, petitions, etc

It would be helpful if anyone can post some link which would help in 
developing a social networking site.

Cheers
Tojo

-- 
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/-/kpImIxg_ZvsJ.
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: static files

2012-10-12 Thread acellam guy
Make sure that all your static settings are okay on your app. Since you
mentioned that you are using apache;
install *mod_wsgi*

 be sure to add some stuff to your httpd.conf file eg;
#added by guy
LoadModule wsgi_module modules/mod_wsgi.so


SSLRandomSeed startup builtin
SSLRandomSeed connect builtin


Alias /appname/robots.txt "absolutepathtoapp/robots.txt"
Alias /appname/favicon.ico "absolutepathtoapp/favicon.ico"

#match main site resources
AliasMatch ^/appname/staticfolder/(.*) absolutepathtoapp/staticfolder/$1

Alias /appname/staticmediafolder/ "absolutepathtoapp/staticmediafolder/"

WSGIScriptAlias /appname"absolutepathtoapp/wsgi.py"


AllowOverride None
Options None
Order deny,allow
Allow from all

#end of added by guy

Replace the words applicably


On Fri, Oct 12, 2012 at 9:46 AM, luca72  wrote:

> Thanks
>  i have try but with no result, i have set as follow:
>
> MEDIA_ROOT =
> '/home/luca72/Scrivania/Quintas_Disegno_definitivo/quintas/quintas/static/'
> MEDIA_URL = '/static/'
> STATIC_URL = ''
> STATIC_ROOT = ''
> STATICFILES_DIRS =
> ('/home/luca72/Scrivania/Quintas_Disegno_definitivo/quintas/quintas/static/',
> inside the static i have made two folders images and css, now in the
> template i load the css in this way   href="..css/base.css" />
>
> But i get that he is not find, but the file base.css is inside the folder.
>
> i think  that i have to configure MEDIA_ and STATIC_ ROOT and URL
> correctly.
>
> Can you help me to configure it.
>
> Thanks
>
> Luca
>
> Il giorno giovedì 11 ottobre 2012 17:07:01 UTC+2, Brad Pitcher ha scritto:
>>
>> I believe the best way of doing this is to have your image(s) in
>> static/images and your css in static/css.  Then you can use a relative URL
>> to set the background image like so:
>>
>> background-image : url("../images/PAE.jpg")
>>
>> It's better not to have any CSS mixed in with your HTML anyway.
>> On Oct 11, 2012 7:49 AM, "luca72"  wrote:
>>
>>> hello my project is lacated here:
>>>
>>> /home/
>>>   /luca72
>>> /Scrivania
>>>   /Quintas_Disegno_definitivo
>>> /quintas/ here i have the file manage.py ,
>>>
>>> than i have the file settings,py here:
>>> /home
>>>/luca72
>>>   /Scrivania
>>>  /Quintas_Disegno_definitivo
>>> /quintas
>>>/quintas, here i have add a folder "static" with and
>>> image called PAE.jpg.
>>>
>>> How i have to configure the file setting.py in a way that in my template
>>> when i write via CSS background-image : url("PAE.jpg") the image is load
>>>
>>> I have try a lot of thing but i get that the image is not found.
>>>
>>> I use apache in localhost.
>>>
>>> Thaks
>>>
>>> Luca
>>>
>>> --
>>> 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/-/**VXS19g9Ie7MJ
>>> .
>>> 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/-/FqgYBYewPcUJ.
>
> 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.



"Writing your first Django app" Tutorial Question

2012-10-12 Thread Rick Chong
Hi, I have just started learning programming and I am following the 
creating a poll app tutorial at:
https://docs.djangoproject.com/en/1.4/intro/tutorial03/

I hope that someone has attempted this tutorial and is able to help me on 
some very beginner questions:

In this app, we defined 2 classes in the model - Poll & Choice:

> import datetime
>
> from django.utils import timezone
>
> from django.db import models
>
>   
>
> # Create your models here.
>
> class Poll(models.Model):
>
> question = models.CharField(max_length=200)
>
> pub_date = models.DateTimeField('date published')
>
> def __unicode__(self):
>
> return self.question
>
> def was_published_recently(self):
>
> return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
>
> was_published_recently.admin_order_field = 'pub_date'
>
> was_published_recently.boolean = True
>
> was_published_recently.short_description = 'Published recently?'
>
>
>> class Choice(models.Model):
>
> poll = models.ForeignKey(Poll)
>
> choice = models.CharField(max_length=200)
>
> votes = models.IntegerField()
>
> def __unicode__(self):
>
> return self.choice
>
>  

Then in views.py... I have the following code:

> from django.shortcuts import render_to_response, get_object_or_404
>
> from polls.models import Poll
>
>
>> def detail(request, poll_id):
>
> p = get_object_or_404(Poll, pk=poll_id)
>
> return render_to_response('polls/detail.html', {'poll': p})
>
>
>

Then in my template, detail.html. I have the following code:

> {{ poll.question }}
>
> 
>
> {% for choice in poll.choice_set.all %}
>
> {{ choice.choice }}
>
> {% endfor %}
>
> 
>
>

 
The scripts run My question:
In views.py, I only import Poll class from model... why am I able to 
display choice, which is a variable under Choice class?


Thank you very much.




Rick

-- 
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/-/2vqJuWiYVuIJ.
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.



Unhandled exception during validation

2012-10-12 Thread Oyvind Idland
Hello,

I am currently trying to upgrade a site from 1.2.x to 1.4.1. When I try to 
start the app, I get this:

Validating models...
Unhandled exception in thread started by <__main__.NewThreadStartup 
instance at 0x03D13738>


Since the output is very economical about info, I spent some time to track 
down the origins. 
I found this in loading.py,  AppCache._populate():

for app_name in settings.INSTALLED_APPS:
if app_name in self.handled:
continue
self.load_app(app_name, True)< CRASH

The app it tries to load, is a local one (made by a co-developer some time 
ago). 

Shouldn't there be better error handling in cases like this, at least 
showing what happened, and where ?
There is no exception handling what so ever..

-- Oyvind


-- 
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/-/g2-0VOwCB04J.
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: perfectionists... motto doesn't fit

2012-10-12 Thread Cal Leeming [Simplicity Media Ltd]
On Fri, Oct 12, 2012 at 3:33 AM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:

> On Fri, Oct 12, 2012 at 9:00 AM, Cal Leeming [Simplicity Media Ltd]
>  wrote:
> > Lets say you if you were given 1 day to build a shed..
> >
> > PHP = build your own hammer/screwdriver from scratch, and then use those
> to
> > build your shed - all within the same timeframe
> > PHP with Zend Framework = the equivalent of trying to build your shed
> with
> > your childs "early learning toolset", using blu-tac for glue.
> > Django = build the shed with the right tools, equipment and materials as
> > your disposal.
>
> Ok - lets back away from this thread right now.
>
> There's absolutely no benefit to be gained in continuing a thread
> whose sole purpose is to debate the merits of a *tagline*.
>

Personally I interpreted it as an interesting topic on what really defines
a perfectionist.. although it doesn't seem to have been perceived this way,
which is sad.

The OP was happy with the "how you got there" thought - it was a simple
question with a simple answer...

I don't know why this thread has been overreacted to :X


>
> There's also absolutely no benefit to be gained by calling other
> framework names, no matter how much you may personally dislike them.
> Ad hominem attacks and name calling will not be tolerated on Django
> mailing lists, and repeat offenders will be banned. You have all been
> warned.


In hindsight I maybe should have put Language X and Framework Y.

These comments weren't intended to be either 'ad hominem' (had to google
that!) or name calling, so my apologies if they were perceived this way.


> Yours,
> Russ Magee %-)
>
> --
> 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.



Re: perfectionists... motto doesn't fit

2012-10-12 Thread Juan Pablo Martínez
gooby pls :)

On Fri, Oct 12, 2012 at 6:49 AM, Moonlight wrote:

>
> Some people make the argument of "whatever tool is right for the job"..
>>
>> Sure - you could make a handsome shed with your first born's plastic tool
>> set, but for perfectionists it's not just about the end result, it's about
>> how you got there.
>>
>
> 'how you got there' - never thought that way. This makes sense to me.
>
> --
> 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/-/DXbx1XuutRMJ.
>
> 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.
>



-- 
juanpex

-- 
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 setup with elsatic beanstalk

2012-10-12 Thread Stefano Tranquillini
Mmm. seems that i missing something.

this is the log

2012-10-12 09:36:51,352 [INFO] (24716 MainThread)
[directoryHooksExecutor.py-28] [root directoryHooksExecutor info] Output
from script: 2012-10-12 09:36:51,331* ERRORThe specified WSGIPath of
"application.py" was not found in the source bundle*

2012-10-12 09:36:51,353 [INFO] (24716 MainThread)
[directoryHooksExecutor.py-28] [root directoryHooksExecutor info] Script
succeeded.
2012-10-12 09:36:51,443 [INFO] (24641 MainThread) [command.py-126] [root
command execute] Command returned: (code: 0, stdout: , stderr: None)
2012-10-12 09:36:51,449 [INFO] (24641 MainThread) [command.py-118] [root
command execute] Executing command: Infra-EmbeddedPostBuild -
AWSEBAutoScalingGroup
2012-10-12 09:36:52,621 [INFO] (24641 MainThread) [command.py-126] [root
command execute] Command returned: (code: 1, stdout: Error occurred during
build: Command 01_syncdb failed
, stderr: None)
2012-10-12 09:36:52,623 [DEBUG] (24641 MainThread) [commandWrapper.py-60]
[root commandWrapper main] Command result: {'status': 'FAILURE', 'results':
[{'status': 'SUCCESS', 'config_set': u'Hook-PreAppDeploy', 'events': [*{'msg':
'Your WSGIPath refers to a file that does not exist.', 'timestamp':
1350034611, 'severity': 'ERROR'}]*}, {'status': 'FAILURE', 'config_set':
u'Infra-EmbeddedPostBuild', 'returncode': 1, 'events': [], 'msg': 'Error
occurred during build: Command 01_syncdb failed\n'}], 'api_version': '1.0'}

what's is this application.py (it's not mentioned in the tutorial) ? idea
about the WSGIPath?

this is the directory tree:

.
|.ebextensions
| |config
|.elasticbeanstalk
| |config
| |optionsettings
|manage.py
|mysites
| |.DS_Store
| |__init__.py
| |__init__.pyc
| |settings.py
| |settings.pyc
| |urls.py
| |urls.pyc
| |wsgi.py
| |wsgi.pyc
|requirements.txt



two things. tutorial says that config file should be .config . it sounds
strange.
is it correct?
where the requirements.txt should be located?



On Thu, Oct 11, 2012 at 6:47 PM, Stefano Tranquillini <
stefano.tranquill...@gmail.com> wrote:

> same problem, did you solve it?
>
>
> On Monday, October 8, 2012 7:22:51 PM UTC+2, shlomi oberman wrote:
>>
>> I'm trying without succes to setup a simple application using django with
>> elastic beanstalk from my windows machine.
>> Does anyone have any expreience with this? I am currently getting the
>> following error from the EB console:
>> "Your WSGIPath refers to a file that does not 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/-/WiWZ2EApeWUJ.
>
> 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.
>



-- 
Stefano

-- 
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: perfectionists... motto doesn't fit

2012-10-12 Thread Moonlight


> Some people make the argument of "whatever tool is right for the job".. 
>
> Sure - you could make a handsome shed with your first born's plastic tool 
> set, but for perfectionists it's not just about the end result, it's about 
> how you got there.
>

'how you got there' - never thought that way. This makes sense to me.

-- 
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/-/DXbx1XuutRMJ.
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: static files

2012-10-12 Thread luca72
Thanks
 i have try but with no result, i have set as follow:

MEDIA_ROOT = 
'/home/luca72/Scrivania/Quintas_Disegno_definitivo/quintas/quintas/static/'
MEDIA_URL = '/static/'
STATIC_URL = ''
STATIC_ROOT = ''
STATICFILES_DIRS = 
('/home/luca72/Scrivania/Quintas_Disegno_definitivo/quintas/quintas/static/',
inside the static i have made two folders images and css, now in the 
template i load the css in this way  

But i get that he is not find, but the file base.css is inside the folder.

i think  that i have to configure MEDIA_ and STATIC_ ROOT and URL correctly.

Can you help me to configure it.

Thanks

Luca 

Il giorno giovedì 11 ottobre 2012 17:07:01 UTC+2, Brad Pitcher ha scritto:
>
> I believe the best way of doing this is to have your image(s) in 
> static/images and your css in static/css.  Then you can use a relative URL 
> to set the background image like so:
>
> background-image : url("../images/PAE.jpg")
>
> It's better not to have any CSS mixed in with your HTML anyway. 
> On Oct 11, 2012 7:49 AM, "luca72"  wrote:
>
>> hello my project is lacated here:
>>
>> /home/
>>   /luca72
>> /Scrivania
>>   /Quintas_Disegno_definitivo
>> /quintas/ here i have the file manage.py , 
>>
>> than i have the file settings,py here: 
>> /home
>>/luca72
>>   /Scrivania
>>  /Quintas_Disegno_definitivo
>> /quintas
>>/quintas, here i have add a folder "static" with and image 
>> called PAE.jpg.
>>
>> How i have to configure the file setting.py in a way that in my template 
>> when i write via CSS background-image : url("PAE.jpg") the image is load
>>
>> I have try a lot of thing but i get that the image is not found.
>>
>> I use apache in localhost.
>>
>> Thaks
>>
>> Luca
>>
>> -- 
>> 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/-/VXS19g9Ie7MJ.
>> 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/-/FqgYBYewPcUJ.
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.



Cleaning up redis connection after client disconnects from streaming response

2012-10-12 Thread Brent Tubbs


I've implemented a Server Sent 
Event API 
in my Django app to stream realtime updates from my backend to the browser. 
The backend is a Redis pubsub. My Django view looks like this:

def event_stream(request):
   """
   Stream worker events out to browser.
   """

   listener = events.Listener(
   settings.EVENTS_PUBSUB_URL,
   channels=[settings.EVENTS_PUBSUB_CHANNEL],
   buffer_key=settings.EVENTS_BUFFER_KEY,
   last_event_id=request.META.get('HTTP_LAST_EVENT_ID')
   )

   return http.HttpResponse(listener, mimetype='text/event-stream')

And the events.Listener class that I'm returning as an iterator looks like 
this:

class Listener(object):
def __init__(self, rcon_or_url, channels, buffer_key=None,
 last_event_id=None):
if isinstance(rcon_or_url, redis.StrictRedis):
self.rcon = rcon_or_url
elif isinstance(rcon_or_url, basestring):
self.rcon = redis.StrictRedis(**utils.parse_redis_url(rcon_or_url))
self.channels = channels
self.buffer_key = buffer_key
self.last_event_id = last_event_id
self.pubsub = self.rcon.pubsub()
self.pubsub.subscribe(channels)

def __iter__(self):
# If we've been initted with a buffer key, then get all the events off
# that and spew them out before blocking on the pubsub.
if self.buffer_key:
buffered_events = self.rcon.lrange(self.buffer_key, 0, -1)
for msg in reversed(list(buffered_events)):
if (self.last_event_id and json.loads(msg)['id'] ==
self.last_event_id):
break
yield to_sse({'data': msg})
try:
for msg in self.pubsub.listen():
if msg['type'] == 'message':
yield to_sse(msg)
finally:
logging.info('Closing pubsub')
self.pubsub.close()
self.rcon.connection_pool.disconnect()

I'm able to successfully stream events out to the browser with this setup. 
However, it seems that the disconnect calls in the listener's "finally" 
don't ever actually get called. I assume that they're still camped out 
waiting for messages to come from the pubsub. As clients disconnect and 
reconnect, I can see the number of connections to my Redis instance 
climbing and never going down. Once it gets to around 1000, Redis starts 
freaking out and consuming all the available CPU.

I would like to be able to detect when the client is no longer listening 
and close the Redis connection(s) at that time.

Things I've tried or thought about:

   1. A connection pool. But as the 
redis-py README 
   states, "It is not safe to pass PubSub or Pipeline objects between threads."
   2. A middleware to handle the connections, or maybe just disconnections. 
   This won't work because a middleware's process_response() method gets 
   called too early (before http headers are even sent to the client). I need 
   something called when the client disconnects while I'm in the middle of 
   streaming content to them.
   3. The 
request_finished
and 
got_request_exception
 signals. 
   The first, like process_response() in a middleware, seems to fire too soon. 
   The second doesn't get called when a client disconnects mid-stream.

Final wrinkle: In production I'm using Gevent so I can get away with 
keeping a lot of connections open at once. However, this connection leak 
issue occurs whether I'm using plain old 'manage.py runserver', or Gevent 
monkeypatched runserver, or Gunicorn's gevent workers.

(Cross-posted 
at 
http://stackoverflow.com/questions/12853067/django-cleaning-up-redis-connection-after-client-disconnects-from-stream.
 
 Answer either here or there... I'll make sure the other gets updated for 
posterity's sake.)

Any help would be greatly appreciated!

Thanks,

Brent

-- 
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/-/_GhEn_UBHI8J.
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.