Re: Difference between signals and celery

2013-12-01 Thread Robin Lery
oh..ok. Thank you so much! :)



Its really great to learn something new.


On Sun, Dec 1, 2013 at 7:42 AM, Avraham Serour  wrote:

> No, you can run celery from the same server, the problem is you won't be
> able to do that on many cheap shared hostings
>
>
> On Sat, Nov 30, 2013 at 7:35 PM, Robin Lery  wrote:
>
>> Thank all so much for you replies. Just one more question though. Does
>> this means Celery needs a different server?
>>
>>
>> On Sat, Nov 30, 2013 at 12:41 AM, Carlos Daniel Ruvalcaba Valenzuela <
>> clsdan...@gmail.com> wrote:
>>
>>> Signals are like events, for example, when the ORM has done an update.
>>> Celery is more like a Task queue, you define code to execute certain task,
>>> load it on celery task server which is running separately from your django
>>> process, then when you need to execute it in the background you tell it,
>>> which usually means sending a message through a broker such as redis or
>>> rabbitmq to the task server, then it gets executed.
>>>
>>> Celery is for background tasks, such as processing images, doing updates
>>> without blocking the main function return, etc. Also celery task can run in
>>> another machine, while signals are executed locally.
>>>
>>> Regards,
>>> Carlos Ruvalcaba
>>>
>>>
>>> On Fri, Nov 29, 2013 at 11:52 AM, Robin Lery wrote:
>>>
 This may be a lame question, but I am really confused with these two. I
 know *signals* are used to do some task when something has happened.
 But what about celery? In the documentation it says:

 *Celery is an asynchronous task queue/job queue based on distributed
 message passing.*

 Will someone please explain to me of what celery is? What's the
 difference between these two and when to use them? Will be much
 appreciated! Thank you.

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

>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAEF3qbkT2tzvHUcqLsTbg_gxY-%2BtdFinn%2BER5F-PdEf_QV-zHg%40mail.gmail.com
>>> .
>>>
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CA%2B4-nGqoCrLoc7BY0Le-7izz7w0qO9-LWWzMZixjWPt5_ZGqCw%40mail.gmail.com
>> .
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAFWa6tL29fSivUpzoT-cYL2qQDFj%2Bv5gmepEN%3DWF0du8SJaJSA%40mail.gmail.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


Re: How to use primary key as an attribute

2013-12-01 Thread Aamu Padi
Actually I need to use *Thread* class in other class as a ForeignKey. Here
is the whole code:

class Thread(models.Model):
thread_pk = models.PositiveIntegerField(default=self.pk)

class ThreadParticipant(models.Model):
thread = models.ForeignKey(Thread)
user = models.ForeignKey(User)

class Message(models.Model):
thread = models.ForeignKey(Thread)
sent_date = models.DateTimeField(default=datetime.now)
body = models.TextField()
user = models.ForeignKey(User)


Is there anyway to create a new message without manually creating a *Thread*.
I mean to auto-populate the Thread, whenever I create a new *Message*?

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


Re: How to get the class name of a ContentType in django

2013-12-01 Thread Aamu Padi
Ok, I will try it! Thank you so very much!!!


On Sun, Dec 1, 2013 at 3:41 AM, Timothy W. Cook  wrote:

> On Sat, Nov 30, 2013 at 3:37 PM, Aamu Padi  wrote:
> > Yes!!! Can I use it as a string in template?
> >
>
>
> I haven't tested it but it seems you should be able to assign it to a
> context variable or kwargs in a view and use it in a template.
>
> Something like:
>
> context['classname'] = type(myinstance)
> or
> kwargs['classname'] = type(myinstance)
>
> HTH,
> Tim
>
> >
> > On Sat, Nov 30, 2013 at 2:45 PM, Timothy W. Cook  wrote:
> >>
> >> You can use type() on your instance(s) to find out their model class.
> >>
> >> If you have an instance of the model:
> >>
> >> stream = StreamItem.objects.create(user,ct,oid,pdate)
> >>
> >> Then type(stream) should return 
> >>
> >> Is that what you wanted?
> >>
> >>
> >>
> >>
> >>
> >> On Sat, Nov 30, 2013 at 1:14 AM, Simon Charette 
> >> wrote:
> >> > Do you want to retrieve the class name of the model class associated
> >> > with a
> >> > content type?
> >> >
> >> > Le jeudi 28 novembre 2013 12:04:34 UTC-5, Aamu Padi a écrit :
> >> >>
> >> >> How do I get the class name in string of a ContentType? I tried it
> this
> >> >> way, but it didn't worked out:
> >> >>
> >> >> class StreamItem(models.Model):
> >> >> user = models.ForeignKey(User)
> >> >> content_type = models.ForeignKey(ContentType)
> >> >> object_id = models.PositiveIntegerField()
> >> >> pub_date = models.DateTimeField(default=datetime.now)
> >> >>
> >> >> content_object = generic.GenericForeignKey('content_type',
> >> >> 'object_id')
> >> >> content_class = content_type.__name__
> >> >>
> >> >> def __unicode__(self):
> >> >> return self.content_class
> >> >>
> >> >> Any help will be much appreciated! Thank you.
> >> >
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> > Groups
> >> > "Django users" group.
> >> > To unsubscribe from this group and stop receiving emails from it, send
> >> > an
> >> > email to django-users+unsubscr...@googlegroups.com.
> >> > To post to this group, send email to django-users@googlegroups.com.
> >> > Visit this group at http://groups.google.com/group/django-users.
> >> > To view this discussion on the web visit
> >> >
> >> >
> https://groups.google.com/d/msgid/django-users/46096fde-2754-49aa-af03-3829a5d1be45%40googlegroups.com
> .
> >> > For more options, visit https://groups.google.com/groups/opt_out.
> >>
> >>
> >>
> >> --
> >> MLHIM VIP Signup: http://goo.gl/22B0U
> >> 
> >> Timothy Cook, MSc   +55 21 94711995
> >> MLHIM http://www.mlhim.org
> >> Like Us on FB: https://www.facebook.com/mlhim2
> >> Circle us on G+: http://goo.gl/44EV5
> >> Google Scholar: http://goo.gl/MMZ1o
> >> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Django users" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an
> >> email to django-users+unsubscr...@googlegroups.com.
> >> To post to this group, send email to django-users@googlegroups.com.
> >> Visit this group at http://groups.google.com/group/django-users.
> >> To view this discussion on the web visit
> >>
> https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3XfRZy7XmTwof5QkNB3oe%2BhF0PVJO_XW8SWi9QdxqnFRg%40mail.gmail.com
> .
> >>
> >> For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to django-users+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group at http://groups.google.com/group/django-users.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/django-users/CAHSNPWsrPg8jC_hmSmgZfuO8KSucjCcb_V4h2PdePUxLwSK3oA%40mail.gmail.com
> .
> >
> > For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
> --
> MLHIM VIP Signup: http://goo.gl/22B0U
> 
> Timothy Cook, MSc   +55 21 94711995
> MLHIM http://www.mlhim.org
> Like Us on FB: https://www.facebook.com/mlhim2
> Circle us on G+: http://goo.gl/44EV5
> Google Scholar: http://goo.gl/MMZ1o
> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3WpkMK95w

Re: How to use primary key as an attribute

2013-12-01 Thread Timothy W. Cook
If I understand what you are building.  You want some way to group
messages into threads? I assume that a Thread will have many messages?
 Unless I am missing something you might want something like this:

class Thread(models.Model):
subject = models.CharField(max_length=256)

class Message(models.Model):
thread = models.ForeignKey(Thread)
sent_date = models.DateTimeField(default=datetime.now)
body = models.TextField()
user = models.ForeignKey(User)

Then you can create a filter for the Thread based on a subject:

selected_subject = Thread.objects.filter(subject="some subject")

Then when you create the message you can use thread =
selected_subject[0] (assuming unique subjects/threads) when you create
your message. OR if 'some subject' isn't found,  len(selected_subject)
== 0 then create a new Thread.

HTH,
Tim



On Sun, Dec 1, 2013 at 8:30 AM, Aamu Padi  wrote:
> Actually I need to use Thread class in other class as a ForeignKey. Here is
> the whole code:
>
> class Thread(models.Model):
> thread_pk = models.PositiveIntegerField(default=self.pk)
>
> class ThreadParticipant(models.Model):
> thread = models.ForeignKey(Thread)
> user = models.ForeignKey(User)
>
> class Message(models.Model):
> thread = models.ForeignKey(Thread)
> sent_date = models.DateTimeField(default=datetime.now)
> body = models.TextField()
> user = models.ForeignKey(User)
>
>
> Is there anyway to create a new message without manually creating a Thread.
> I mean to auto-populate the Thread, whenever I create a new Message?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHSNPWt14jxduA_kT-Yxj-7k02qZzZkvkbfYU2pEPFghbNq%3DEg%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
MLHIM VIP Signup: http://goo.gl/22B0U

Timothy Cook, MSc   +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

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


Re: How to get the class name of a ContentType in django

2013-12-01 Thread Timothy W. Cook
Be sure to post the results back here for the archive so others may
find it in searches.

On Sun, Dec 1, 2013 at 8:32 AM, Aamu Padi  wrote:
> Ok, I will try it! Thank you so very much!!!
>
>
> On Sun, Dec 1, 2013 at 3:41 AM, Timothy W. Cook  wrote:
>>
>> On Sat, Nov 30, 2013 at 3:37 PM, Aamu Padi  wrote:
>> > Yes!!! Can I use it as a string in template?
>> >
>>
>>
>> I haven't tested it but it seems you should be able to assign it to a
>> context variable or kwargs in a view and use it in a template.
>>
>> Something like:
>>
>> context['classname'] = type(myinstance)
>> or
>> kwargs['classname'] = type(myinstance)
>>
>> HTH,
>> Tim
>>
>> >
>> > On Sat, Nov 30, 2013 at 2:45 PM, Timothy W. Cook  wrote:
>> >>
>> >> You can use type() on your instance(s) to find out their model class.
>> >>
>> >> If you have an instance of the model:
>> >>
>> >> stream = StreamItem.objects.create(user,ct,oid,pdate)
>> >>
>> >> Then type(stream) should return 
>> >>
>> >> Is that what you wanted?
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> On Sat, Nov 30, 2013 at 1:14 AM, Simon Charette 
>> >> wrote:
>> >> > Do you want to retrieve the class name of the model class associated
>> >> > with a
>> >> > content type?
>> >> >
>> >> > Le jeudi 28 novembre 2013 12:04:34 UTC-5, Aamu Padi a écrit :
>> >> >>
>> >> >> How do I get the class name in string of a ContentType? I tried it
>> >> >> this
>> >> >> way, but it didn't worked out:
>> >> >>
>> >> >> class StreamItem(models.Model):
>> >> >> user = models.ForeignKey(User)
>> >> >> content_type = models.ForeignKey(ContentType)
>> >> >> object_id = models.PositiveIntegerField()
>> >> >> pub_date = models.DateTimeField(default=datetime.now)
>> >> >>
>> >> >> content_object = generic.GenericForeignKey('content_type',
>> >> >> 'object_id')
>> >> >> content_class = content_type.__name__
>> >> >>
>> >> >> def __unicode__(self):
>> >> >> return self.content_class
>> >> >>
>> >> >> Any help will be much appreciated! Thank you.
>> >> >
>> >> > --
>> >> > You received this message because you are subscribed to the Google
>> >> > Groups
>> >> > "Django users" group.
>> >> > To unsubscribe from this group and stop receiving emails from it,
>> >> > send
>> >> > an
>> >> > email to django-users+unsubscr...@googlegroups.com.
>> >> > To post to this group, send email to django-users@googlegroups.com.
>> >> > Visit this group at http://groups.google.com/group/django-users.
>> >> > To view this discussion on the web visit
>> >> >
>> >> >
>> >> > https://groups.google.com/d/msgid/django-users/46096fde-2754-49aa-af03-3829a5d1be45%40googlegroups.com.
>> >> > For more options, visit https://groups.google.com/groups/opt_out.
>> >>
>> >>
>> >>
>> >> --
>> >> MLHIM VIP Signup: http://goo.gl/22B0U
>> >> 
>> >> Timothy Cook, MSc   +55 21 94711995
>> >> MLHIM http://www.mlhim.org
>> >> Like Us on FB: https://www.facebook.com/mlhim2
>> >> Circle us on G+: http://goo.gl/44EV5
>> >> Google Scholar: http://goo.gl/MMZ1o
>> >> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "Django users" group.
>> >> To unsubscribe from this group and stop receiving emails from it, send
>> >> an
>> >> email to django-users+unsubscr...@googlegroups.com.
>> >> To post to this group, send email to django-users@googlegroups.com.
>> >> Visit this group at http://groups.google.com/group/django-users.
>> >> To view this discussion on the web visit
>> >>
>> >> https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3XfRZy7XmTwof5QkNB3oe%2BhF0PVJO_XW8SWi9QdxqnFRg%40mail.gmail.com.
>> >>
>> >> For more options, visit https://groups.google.com/groups/opt_out.
>> >
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Django users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to django-users+unsubscr...@googlegroups.com.
>> > To post to this group, send email to django-users@googlegroups.com.
>> > Visit this group at http://groups.google.com/group/django-users.
>> > To view this discussion on the web visit
>> >
>> > https://groups.google.com/d/msgid/django-users/CAHSNPWsrPg8jC_hmSmgZfuO8KSucjCcb_V4h2PdePUxLwSK3oA%40mail.gmail.com.
>> >
>> > For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>> --
>> MLHIM VIP Signup: http://goo.gl/22B0U
>> 
>> Timothy Cook, MSc   +55 21 94711995
>> MLHIM http://www.mlhim.org
>> Like Us on FB: https://www.facebook.com/mlhim2
>> Circle us on G+: http://goo.gl/44EV5
>> Google Scholar: http://goo.gl/MMZ1o
>> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it

Can i Use history.js in Django?

2013-12-01 Thread Robert Jonathan Šimon
Hello everyone,
I want to use history.js on one page in my website, where there will be a 
photo gallery, and I want to know before I will write the code, if it can 
be done, and if so is there any problem  with it?

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


Django Weekend Cardiff - call for papers

2013-12-01 Thread Daniele Procida
Django Weekend Cardiff  - the first-ever Django 
conference in the UK -  will  take place from the 7th to the 9th February 2014, 
for three days of talks, tutorials, code sprints and clinics.
 
The conference is Django-focused, but all aspects of Python fall within its 
remit.

We invite members of the Python/Django communities to submit their talk and 
other proposals for the event: .

Talks
-

Do you have something to share with the rest of the community? Proposals on any 
subject are welcomed, at any level of technical expertise. Tell us about your 
experiments, discoveries, solutions, achievements and other adventures.



The deadline for proposals is the end of Monday 6th January 2014, GMT. Feel 
free to submit more than one!

Workshops & tutorials
-

The first day of this event will be dedicated to tutorials, workshops and 
demonstrations, some of which will be open the wider public.

Can you lead a tutorial, on a Python or Django topic? Can you demonstrate the 
power of Django to people who don't know about it? Do you have an application 
or product or service that you'd like to showcase?

Just let us know: . We're open to all kinds of 
suggestions, and especially ideas we haven't even thought of.

Sprints & clinics
-

No Django or Python event would be complete without code sprints. There'll be a 
Django sprint, led by at least a couple of core Django developers.

We'd like to get as many people as possible to stay for the sprints, and 
particularly new people who haven't taken part before. To encourage people to 
join in:

* we'll be supporting the sprints with a "Don't be afraid to commit" workshop 
on the tutorials day, aimed specially at those who would like to take part but 
aren't sure they have the skills - yet

* we'll be holding code clinics alongside the sprints, where you can put your 
questions or problems to a Python or Django expert

A particular clinic might run for minutes 45 or an hour or so. If you like to 
offer a clinic on a particular subject, or even a general one, please get in 
touch: . We'd love to hear from you.

On behalf of Django Weekend Cardiff,

Daniele


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


Re: How to use primary key as an attribute

2013-12-01 Thread Aamu Padi
You are really are a life saver. Thank you so much sir. I have posted a
more specific question. Please kindly have a look at it.
Thank you.


On Sun, Dec 1, 2013 at 5:09 PM, Timothy W. Cook  wrote:

> If I understand what you are building.  You want some way to group
> messages into threads? I assume that a Thread will have many messages?
>  Unless I am missing something you might want something like this:
>
> class Thread(models.Model):
> subject = models.CharField(max_length=256)
>
> class Message(models.Model):
> thread = models.ForeignKey(Thread)
> sent_date = models.DateTimeField(default=datetime.now)
> body = models.TextField()
> user = models.ForeignKey(User)
>
> Then you can create a filter for the Thread based on a subject:
>
> selected_subject = Thread.objects.filter(subject="some subject")
>
> Then when you create the message you can use thread =
> selected_subject[0] (assuming unique subjects/threads) when you create
> your message. OR if 'some subject' isn't found,  len(selected_subject)
> == 0 then create a new Thread.
>
> HTH,
> Tim
>
>
>
> On Sun, Dec 1, 2013 at 8:30 AM, Aamu Padi  wrote:
> > Actually I need to use Thread class in other class as a ForeignKey. Here
> is
> > the whole code:
> >
> > class Thread(models.Model):
> > thread_pk = models.PositiveIntegerField(default=self.pk)
> >
> > class ThreadParticipant(models.Model):
> > thread = models.ForeignKey(Thread)
> > user = models.ForeignKey(User)
> >
> > class Message(models.Model):
> > thread = models.ForeignKey(Thread)
> > sent_date = models.DateTimeField(default=datetime.now)
> > body = models.TextField()
> > user = models.ForeignKey(User)
> >
> >
> > Is there anyway to create a new message without manually creating a
> Thread.
> > I mean to auto-populate the Thread, whenever I create a new Message?
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to django-users+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group at http://groups.google.com/group/django-users.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/django-users/CAHSNPWt14jxduA_kT-Yxj-7k02qZzZkvkbfYU2pEPFghbNq%3DEg%40mail.gmail.com
> .
> >
> > For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
> --
> MLHIM VIP Signup: http://goo.gl/22B0U
> 
> Timothy Cook, MSc   +55 21 94711995
> MLHIM http://www.mlhim.org
> Like Us on FB: https://www.facebook.com/mlhim2
> Circle us on G+: http://goo.gl/44EV5
> Google Scholar: http://goo.gl/MMZ1o
> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3XsrpZ5U-2626-r4dTvQgoeXUiKY%3Dvx1Yp5dPjHKYnr0A%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


auto populating the fields in the models

2013-12-01 Thread Aamu Padi
Hello, please have a look at my models.py.

*models.py:*

> class Thread(models.Model):
> pass
>
> class ThreadParticipant(models.Model):
> thread = models.ForeignKey(Thread)
> user = models.ForeignKey(User)
>
> class Message(models.Model):
> thread = models.ForeignKey(Thread)
> sent_date = models.DateTimeField(default=datetime.now)
> body = models.TextField()
> user = models.ForeignKey(User)
>
> class MessageReadState(models.Model):
> message = models.ForeignKey(Message)
> user = models.ForeignKey(User)
> read_date = models.DateTimeField()
>
I am having two problems when I try to create a new message:

   1. How do I auto populate the Thread with its primary key whenever I
   create a new message, without manually creating a new thread?
   2. How to create a new user if the user is not in the the
   ThreadParticipant, or else don't create a new user?

I think I can solve this all in the views.py, but I think it will be better
to solve this in the models.py. Please help me solve the problem. I would
be very grateful. Thank you.

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


Re: auto populating the fields in the models

2013-12-01 Thread Rafael E. Ferrero
IMHO with this design you first need an user and a thread to create a new
message.

In the admin interface you gonna look a + button to create a user and other
to create a thread.

For example
class Message(models.Model):
thread = models.ForeignKey(Thread)
sent_date = models.DateTimeField(default=datetime.now)
body = models.TextField()
user = models.ForeignKey(User)

def save(self):
if not self.id:
#on a new message do something
#on modify message do somenthing else
super(Message, self).save()






2013/12/1 Aamu Padi 

> Hello, please have a look at my models.py.
>
> *models.py:*
>
>> class Thread(models.Model):
>> pass
>>
>> class ThreadParticipant(models.Model):
>> thread = models.ForeignKey(Thread)
>> user = models.ForeignKey(User)
>>
>> class Message(models.Model):
>> thread = models.ForeignKey(Thread)
>> sent_date = models.DateTimeField(default=datetime.now)
>> body = models.TextField()
>> user = models.ForeignKey(User)
>>
>> class MessageReadState(models.Model):
>> message = models.ForeignKey(Message)
>> user = models.ForeignKey(User)
>> read_date = models.DateTimeField()
>>
> I am having two problems when I try to create a new message:
>
>1. How do I auto populate the Thread with its primary key whenever I
>create a new message, without manually creating a new thread?
>2. How to create a new user if the user is not in the the
>ThreadParticipant, or else don't create a new user?
>
> I think I can solve this all in the views.py, but I think it will be
> better to solve this in the models.py. Please help me solve the problem. I
> would be very grateful. Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHSNPWsLC1LW1pqpYe-FUmC4k4twxBV8HrLxRex4e6VNicoBdQ%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Rafael E. Ferrero

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


Re: auto populating the fields in the models

2013-12-01 Thread Rafael E. Ferrero
sorry my previous message... it was not quite clear... here again:



2013/12/1 Rafael E. Ferrero 

> IMHO with this design you first need an user and a thread to create a new
> message.
>
> In the admin interface you gonna look a + button to create a user and
> other to create a thread.
>


OR

You can redefine the save method of your model. For example:


>
> For example
>
> class Message(models.Model):
> thread = models.ForeignKey(Thread)
> sent_date = models.DateTimeField(default=datetime.now)
> body = models.TextField()
> user = models.ForeignKey(User)
>
> def save(self):
> if not self.id:
> #on a new message do something
> #on modify message do somenthing else
> super(Message, self).save()
>
>
>
>
>
>
> 2013/12/1 Aamu Padi 
>
>> Hello, please have a look at my models.py.
>>
>> *models.py:*
>>
>>> class Thread(models.Model):
>>> pass
>>>
>>> class ThreadParticipant(models.Model):
>>> thread = models.ForeignKey(Thread)
>>> user = models.ForeignKey(User)
>>>
>>> class Message(models.Model):
>>> thread = models.ForeignKey(Thread)
>>> sent_date = models.DateTimeField(default=datetime.now)
>>> body = models.TextField()
>>> user = models.ForeignKey(User)
>>>
>>> class MessageReadState(models.Model):
>>> message = models.ForeignKey(Message)
>>> user = models.ForeignKey(User)
>>> read_date = models.DateTimeField()
>>>
>> I am having two problems when I try to create a new message:
>>
>>1. How do I auto populate the Thread with its primary key whenever I
>>create a new message, without manually creating a new thread?
>>2. How to create a new user if the user is not in the the
>>ThreadParticipant, or else don't create a new user?
>>
>> I think I can solve this all in the views.py, but I think it will be
>> better to solve this in the models.py. Please help me solve the problem. I
>> would be very grateful. Thank you.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAHSNPWsLC1LW1pqpYe-FUmC4k4twxBV8HrLxRex4e6VNicoBdQ%40mail.gmail.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> --
> Rafael E. Ferrero
>



-- 
Rafael E. Ferrero

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


Re: auto populating the fields in the models

2013-12-01 Thread Aamu Padi
Yes, that's what I was looking for, the save method. Can you please kindly
show me how, so that I don't have to create a new thread first or create a
new set of ThreadParticipants. I just want it to be on the background, so
that all I have to do is create a message and send it to the user.
Thank you.


On Sun, Dec 1, 2013 at 9:14 PM, Rafael E. Ferrero
wrote:

> sorry my previous message... it was not quite clear... here again:
>
>
>
> 2013/12/1 Rafael E. Ferrero 
>
> IMHO with this design you first need an user and a thread to create a new
>> message.
>>
>> In the admin interface you gonna look a + button to create a user and
>> other to create a thread.
>>
>
>
> OR
>
> You can redefine the save method of your model. For example:
>
>
>>
>> For example
>>
>> class Message(models.Model):
>> thread = models.ForeignKey(Thread)
>> sent_date = models.DateTimeField(default=datetime.now)
>> body = models.TextField()
>> user = models.ForeignKey(User)
>>
>> def save(self):
>> if not self.id:
>> #on a new message do something
>> #on modify message do somenthing else
>> super(Message, self).save()
>>
>>
>>
>>
>>
>>
>> 2013/12/1 Aamu Padi 
>>
>>> Hello, please have a look at my models.py.
>>>
>>> *models.py:*
>>>
 class Thread(models.Model):
 pass

 class ThreadParticipant(models.Model):
 thread = models.ForeignKey(Thread)
 user = models.ForeignKey(User)

 class Message(models.Model):
 thread = models.ForeignKey(Thread)
 sent_date = models.DateTimeField(default=datetime.now)
 body = models.TextField()
 user = models.ForeignKey(User)

 class MessageReadState(models.Model):
 message = models.ForeignKey(Message)
 user = models.ForeignKey(User)
 read_date = models.DateTimeField()

>>> I am having two problems when I try to create a new message:
>>>
>>>1. How do I auto populate the Thread with its primary key whenever I
>>>create a new message, without manually creating a new thread?
>>>2. How to create a new user if the user is not in the the
>>>ThreadParticipant, or else don't create a new user?
>>>
>>> I think I can solve this all in the views.py, but I think it will be
>>> better to solve this in the models.py. Please help me solve the problem. I
>>> would be very grateful. Thank you.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAHSNPWsLC1LW1pqpYe-FUmC4k4twxBV8HrLxRex4e6VNicoBdQ%40mail.gmail.com
>>> .
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>
>>
>> --
>> Rafael E. Ferrero
>>
>
>
>
> --
> Rafael E. Ferrero
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJJc_8VJCH01_SQZKOkAz%3DhwHgC%3Dsj-w%3DKLQTxJc1K92RZ11jw%40mail.gmail.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


Re: Difference between signals and celery

2013-12-01 Thread fchow
Question:  If a view saves a model that has a post-save hook, does the view 
return after the post-save hook has completed? Or does the view return and 
the hook runs in the background like a celery task would?  

On Friday, November 29, 2013 10:52:04 AM UTC-8, Robin Lery wrote:
>
> This may be a lame question, but I am really confused with these two. I 
> know *signals* are used to do some task when something has happened. But 
> what about celery? In the documentation it says:
>
> *Celery is an asynchronous task queue/job queue based on distributed 
> message passing.*
>
> Will someone please explain to me of what celery is? What's the difference 
> between these two and when to use them? Will be much appreciated! Thank you.
>

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


Re: Can i Use history.js in Django?

2013-12-01 Thread Scot Hacker
On Sunday, December 1, 2013 4:21:33 AM UTC-8, Robert Jonathan Šimon wrote:
>
> Hello everyone,
> I want to use history.js on one page in my website, where there will be a 
> photo gallery, and I want to know before I will write the code, if it can 
> be done, and if so is there any problem  with it?
>

 Django is a back-end framework and thus completely agnostic about your 
front-end toolchain - go for it.

./s

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


Inconsistent Django test results depending upon how the test is called in Django 1.5.1 running on Python 2.7.4

2013-12-01 Thread Paul Whipp


I have test cases that pass when tested individually, pass when the full 
app is tested but fail when the tests for the entire project are run:

(lsapi)~ $ django test
Creating test database for alias 'default'...
.s.x..Exception
 RuntimeError: 'maximum recursion depth exceeded' in  ignored
Exception RuntimeError: 'maximum recursion depth exceeded' in  ignored
Exception RuntimeError: 'maximum recursion depth exceeded' in  ignored
...ssE.E.E.Setting
 content_object to liquid app one
.EEE....
==
ERROR: test_get_direct_notes (lsapi.tests.DirectGetTestCase)
--
Traceback (most recent call last):
  File "ls-api/lsapi/tests.py", line 869, in _method

  File "ls-core/lscore/model/note.py", line 37, in company
return self.content_object.company
AttributeError: 'NoneType' object has no attribute 'company'
...


(lsapi)~ $ django test lsapi.NotesTestCase.test_wrong_user_cannot_put
Creating test database for alias 'default'...
.
--
Ran 1 test in 0.241s

OK
Destroying test database for alias 'default'...


(lsapi)~ $ django test lsapi
Creating test database for alias 'default'...
...ss..Setting
 content_object to liquid app one
...Exception RuntimeError: 'maximum recursion depth exceeded 
while calling a Python object' in <_ctypes.DictRemover object at 0x46dac70> 
ignored
.
--
Ran 303 tests in 71.469s

OK (skipped=2)
Destroying test database for alias 'default'...

The 'django' command is an alias for django-admin.py. So the tests pass if 
run as a single case or as a test suite when testing the entire app but 
fail with errors if run when running the tests for all of the apps in the 
project.

Investigating the error in the full suite test: It is the result of an 
attribute being None when it 'should' have a value. The attribute is a 
content_object set up in a fixture.

I added a debugging setattr on the class and nothing is setting it to None 
so it seems that the fixture code is not being properly executed to set up 
the object leading to the errors. The fixture is using content types 
because it is for 'notes' that can be associated with various model classes:

notes.py:

...
class Note(TimeStampedModel):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
...
def __setattr__(self, key, value):
if key == 'content_object':
if value is None:
import pdb; pdb.set_trace()
print('Setting content_object to {0}'.format(value))
return super(Note, self).__setattr__(key, value)

local_test.json:

...
 {"pk": 1, "model": "lscore.note",
  "fields": {"content_type": 16,
 "object_id": 2,
 "created_by": 4,
 "text": "This is the note text"}},
...

Thinking on this further, GenericForeignKey is likely to work by accessing 
the content_type/object_id fields and the fixtures code will be responsible 
for putting these directly into the database. On this basis, I trapped the 
error and investigated the database at the point when it occurred in the 
full suite test. Sure enough, the content object has not been set in the 
test database when the error occurs. The above fixture works fine in the 
other test invocations and all of the fixtures are in a single file which 
is the only fixtures file specified and loaded for the test case.

Looking at the recursion errors which only occur on the full suite testing 
and which might conceivably have something to do with this, I added 
sys.setrecursionlimit(3000) to the relevant tests.py file. This eliminated 
the recursion errors but had no effect on the test errors describe

Re: python virtual environment

2013-12-01 Thread Paul Whipp
Looks like you already have an active virtual environment but those 
instructions only install a few default things (like Django) into that 
environment.

Therefore it sounds like your new virtual environment does not have all of 
the required python modules installed in it.

There should be a requirements.txt file or similar associated with the 
project which you can use for the purpose with pip. See 
herefor more info.

On Sunday, 1 December 2013 12:13:28 UTC+10, Avraham Serour wrote:
>
> you need to activate the virtualenv before using:
> on windows:
> env\Scripts\activate
> on linux:
> source env/bin/activate
>
>
> On Fri, Nov 29, 2013 at 7:44 PM, tino >wrote:
>
>>
>>
>> Hello
>>
>> I am trying to run a project that was setup in another server, but 
>> getting the following error. I am using python 2.7, django, virtualenv. So 
>> I am running the project inside a python virtual environment
>>
>>
>> (virtualenv)[web.srv1 daily# python manage.py runserver 0.0.0.0:8000
>> Traceback (most recent call last):
>>   File "manage.py", line 2, in 
>> from django.core.management import execute_manager
>> ImportError: cannot import name execute_manager
>>
>>
>> I used the method mentioned in the below link to setup the virtual 
>> environment.
>>
>> http://toic.org/blog/2011/wsgi-on-cpanel-improved/
>>
>> This project was setup inside a cpanel server. But the current server I 
>> using is not a cpanel server. It is normal centos server.
>>
>> Can somebody help me to track down the issue.
>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/7181ba64-d2d6-4926-b35d-5b4a2a7792a4%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

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


Re: Inconsistent Django test results depending upon how the test is called in Django 1.5.1 running on Python 2.7.4

2013-12-01 Thread Russell Keith-Magee
On Mon, Dec 2, 2013 at 8:24 AM, Paul Whipp  wrote:

> I have test cases that pass when tested individually, pass when the full
> app is tested but fail when the tests for the entire project are run:
>
> (lsapi)~ $ django test
> Creating test database for alias 'default'...
> .s.x..Exception
>  RuntimeError: 'maximum recursion depth exceeded' in  0x13447d0> ignored
> Exception RuntimeError: 'maximum recursion depth exceeded' in  remove at 0x13447d0> ignored
> Exception RuntimeError: 'maximum recursion depth exceeded' in  remove at 0x13447d0> ignored
> ...ssE.E.E.Setting
>  content_object to liquid app one
> .EEE....
> ==
> ERROR: test_get_direct_notes (lsapi.tests.DirectGetTestCase)
> --
> Traceback (most recent call last):
>   File "ls-api/lsapi/tests.py", line 869, in _method
> 
>   File "ls-core/lscore/model/note.py", line 37, in company
> return self.content_object.company
> AttributeError: 'NoneType' object has no attribute 'company'
> ...
>
>
> (lsapi)~ $ django test lsapi.NotesTestCase.test_wrong_user_cannot_put
> Creating test database for alias 'default'...
> .
> --
> Ran 1 test in 0.241s
>
> OK
> Destroying test database for alias 'default'...
>
>
> (lsapi)~ $ django test lsapi
> Creating test database for alias 'default'...
> ...ss..Setting
>  content_object to liquid app one
> ...Exception RuntimeError: 'maximum recursion depth exceeded 
> while calling a Python object' in <_ctypes.DictRemover object at 0x46dac70> 
> ignored
> .
> --
> Ran 303 tests in 71.469s
>
> OK (skipped=2)
> Destroying test database for alias 'default'...
>
> The 'django' command is an alias for django-admin.py. So the tests pass if
> run as a single case or as a test suite when testing the entire app but
> fail with errors if run when running the tests for all of the apps in the
> project.
>
> Investigating the error in the full suite test: It is the result of an
> attribute being None when it 'should' have a value. The attribute is a
> content_object set up in a fixture.
>
This is an example of a really annoying edge cases that exists sometimes in
Django's own test suite. Despite all our best efforts, sometimes unit tests
don't clean up after themselves, so the order of execution matters.

The test passes when it runs by itself because it gets a completely new
environment when it runs. However, the test fails when run in the full
suite because one of the tests that proceeds it leaves behind some detritus
in the test database that effects the execution of the failing test.

> Can anyone shed any light on this or let me know how I might address the
> problem?
>
> There's two tasks here:

1) Find the individual test that, when paired with the failing test, causes
test failure.

2) Fix the test that causes the problem.

The first task is laborious, but not especially difficult. Test execution
order in Django is predictable, so you just need to do a binary search
until you find a pair of tests that causes the problem. Lets say your suite
contains apps A, B, C and D, and C.TestModel.test_problem that is causing
the problem. Run:

 ./manage.py test A C.TestModel.test_problem

>  ./manage.py test B C.TestModel.test_problem

>  ./manage.py test D C.TestModel.test_problem

Normally, one of these three test executions will cause the failure, and
the other two will pass. Let's B is the causes the failure. Now run:

 ./manage.py test B.TestModel1 C.TestModel.test_problem

>  ./manage.py test B.TestModel2 C.TestModel.test_problem

>  ./manage.py test B.TestModel3 C.TestModel.test_problem

>
Where TestModel[n] are the various test cases in the B app. Again, one of
these will fail. Repeat again for individual tests; you should the

Re: Finished and Published Tango with Rango Tutorials

2013-12-01 Thread Amimo Benja
Yeah, that's what I also thought... I will update the recommended
changes... Thanks Lee.


On Sat, Nov 30, 2013 at 11:09 PM, Lee  wrote:

> Presumably you are talking about the left menu being broken and the 'Find
> a category' not working?
>
> For the first, looks like you are missing a closing div for the top nav
> bar. Regarding the Find a category not working, I had the same issue and
> there was a problem in the tutorial with an extra tab that should not have
> been there. If I recall, the issue was in the suggest_category view and it
> relates to the following line:
>
> cat_list = get_category_list(8, starts_with)
>
>
> That line should not be tabbed as shown in the tutorial as the tab causes
> it to become part of the above else and so cat_list is not populates as
> expected. Have a look at the final code from the reference site:
>
>
> https://github.com/leifos/tango_with_django/blob/master/tango_with_django_project/rango/views.py
>
>
> On Saturday, 30 November 2013 12:31:13 UTC, Amimo Benja wrote:
>>
>> Hello,
>>
>> I finished the Tango with Rango Tutorials and published the app at
>> amimobenja.pythonanywhere.com/rango/ however it is not working as
>> expected.
>>
>> Check out the site and review the whole whole code at https://github.com/
>> amimobenja/tango_with_django and recommend any necessary changes.
>>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/qfC7vgTY4jg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/69476e68-6cd3-4c75-87ed-497f398bca10%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

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