Re: Django M2M with Oracle database FieldDoesNotExist error

2016-06-10 Thread Felipe Horta
Hi everyone, I'm following this thread and I'm having the same error. Im 
running a postgis db, and despite the biginteger pk, my problem is the 
same. Could you solve it?

Thanks!

On Monday, August 3, 2015 at 11:16:12 PM UTC-6, mohse...@gmail.com wrote:
>
> i found that even trying to access the relation (i.e. foo.bars) will 
> trigger the same error !!!
> the only special thing about my model is that i defined foo's primary key 
> as BigIntegerField
>
> On Tuesday, August 4, 2015 at 8:15:42 AM UTC+4:30, mohse...@gmail.com 
> wrote:
>>
>> Erik, as stated in documentation 
>> ,
>>  
>> what you said is equivalent to what i did
>> and the error exists yet. to have more details, here is the stack trace:
>>
>> Traceback (most recent call last):
>>   File "", line 2, in 
>>   File "/home/user/Workspace/src/models.py", line 155, in 
>> create_from_dict
>> obj.bars.clear()
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/related.py"
>> , line 1253, in __get__
>> through=self.field.rel.through,
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/related.py"
>> , line 862, in __init__
>> source_field = through._meta.get_field(source_field_name)
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", 
>> line 554, in get_field
>> raise FieldDoesNotExist('%s has no field named %r' % (self.
>> object_name, field_name))
>> FieldDoesNotExist: Foo_bars has no field named None
>>
>>
>>
>>
>> On Monday, August 3, 2015 at 3:01:28 PM UTC+4:30, Erik Cederstrand wrote:
>>>
>>>
>>> > Den 03/08/2015 kl. 08.50 skrev mohse...@gmail.com: 
>>> > 
>>> > Hello Django community. 
>>> > I have two Django models Foo and Bar that have a  ManyToMany relation: 
>>> > 
>>> > Class Foo(models.model): 
>>> >   
>>> > ... 
>>> > 
>>> >   bars = models.ManyToManyField('Bar', related_name='foos') 
>>> > somewhere in the code, i do direct assignment to replace the relation 
>>> with a new list: 
>>> > 
>>> > foo_object.bars = [bar_object_list] 
>>>
>>> You can't do that, AFAIK. You need to do: 
>>>
>>>  foo_object.bars.clear() 
>>>  foo_object.bars.add(*bar_object_list) 
>>>
>>>
>>> Erik
>>
>>
On Monday, August 3, 2015 at 11:16:12 PM UTC-6, mohse...@gmail.com wrote:
>
> i found that even trying to access the relation (i.e. foo.bars) will 
> trigger the same error !!!
> the only special thing about my model is that i defined foo's primary key 
> as BigIntegerField
>
> On Tuesday, August 4, 2015 at 8:15:42 AM UTC+4:30, mohse...@gmail.com 
> wrote:
>>
>> Erik, as stated in documentation 
>> ,
>>  
>> what you said is equivalent to what i did
>> and the error exists yet. to have more details, here is the stack trace:
>>
>> Traceback (most recent call last):
>>   File "", line 2, in 
>>   File "/home/user/Workspace/src/models.py", line 155, in 
>> create_from_dict
>> obj.bars.clear()
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/related.py"
>> , line 1253, in __get__
>> through=self.field.rel.through,
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/related.py"
>> , line 862, in __init__
>> source_field = through._meta.get_field(source_field_name)
>>   File 
>> "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", 
>> line 554, in get_field
>> raise FieldDoesNotExist('%s has no field named %r' % (self.
>> object_name, field_name))
>> FieldDoesNotExist: Foo_bars has no field named None
>>
>>
>>
>>
>> On Monday, August 3, 2015 at 3:01:28 PM UTC+4:30, Erik Cederstrand wrote:
>>>
>>>
>>> > Den 03/08/2015 kl. 08.50 skrev mohse...@gmail.com: 
>>> > 
>>> > Hello Django community. 
>>> > I have two Django models Foo and Bar that have a  ManyToMany relation: 
>>> > 
>>> > Class Foo(models.model): 
>>> >   
>>> > ... 
>>> > 
>>> >   bars = models.ManyToManyField('Bar', related_name='foos') 
>>> > somewhere in the code, i do direct assignment to replace the relation 
>>> with a new list: 
>>> > 
>>> > foo_object.bars = [bar_object_list] 
>>>
>>> You can't do that, AFAIK. You need to do: 
>>>
>>>  foo_object.bars.clear() 
>>>  foo_object.bars.add(*bar_object_list) 
>>>
>>>
>>> Erik
>>
>>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f55cceb5-2c6a-43c9-b4d0-446f8c0011bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Display objects from different models at the same page according to their published date

2016-06-10 Thread Aamu Padi
Yes, I too was thinking about that. I had doubts about the space and the
performance of it. Do you see any downside \on the space and performance?

On Fri, Jun 10, 2016 at 6:57 PM, Rafael Guillén  wrote:

> Instead of making them entirely separate models, you can use one model as
> a base and have the other models inherit from them, then you display the
> base model. I think this might be a good fit for multi-table inheritance.
> See if this helps:
>
> https://docs.djangoproject.com/en/1.9/topics/db/models/#model-inheritance
>
>
> On Friday, June 10, 2016 at 6:59:55 AM UTC-5, Aamu Padi wrote:
>>
>> This is just a follow up of my question.
>>
>> I don't want to show each of the model objects separately at the same
>> page. But like feeds of facebook or any other social media. Suppose a new
>> Job object was created, and after that a new News object is created. Then,
>> I want to show the News object first, and then the Job object, and so on.
>>
>> On Fri, Jun 10, 2016 at 5:12 PM, Aamu Padi  wrote:
>>
>>> I have three different models for my app. All are working as I expected.
>>>
>>> class Tender(models.Model):
>>> title = models.CharField(max_length=256)
>>> description = models.TextField()
>>> department = models.CharField(max_length=50)
>>> address = models.CharField(max_length=50)
>>> nature_of_work = models.CharField(choices=WORK_NATURE,
>>> max_length=1)
>>> period_of_completion = models.DateField()
>>> pubdat = models.DateTimeField(default=timezone.now)
>>>
>>> class Job(models.Model):
>>> user = models.ForeignKey(settings.AUTH_USER_MODEL)
>>> title = models.CharField(max_length=256)
>>> qualification = models.CharField(max_length=256)
>>> interview_type = models.CharField(max_length=2,
>>> choices=INTERVIEW_TYPE)
>>> type_of_job = models.CharField(max_length=1, choices=JOB_TYPE)
>>> number_of_vacancies = models.IntegerField()
>>> employer = models.CharField(max_length=50)
>>> salary = models.IntegerField()
>>> pubdat = models.DateTimeField(default=timezone.now)
>>>
>>> class News(models.Model):
>>> user = models.ForeignKey(settings.AUTH_USER_MODEL)
>>> title = models.CharField(max_length=150)
>>> body = models.TextField()
>>> pubdat = models.DateTimeField(default=timezone.now)
>>>
>>> Now I am displaying each of them at separate page for each of the model
>>> (e.g. in the *jobs* page, I am displaying only the jobs.). But now at the
>>> home page, I want to display these according to their published date at the
>>> same page. How can I display different objects from different models at the
>>> same page? Do I make a separate model e.g. `class Post` and then use signal
>>> to create a new post whenever a new object is created from `Tender`, or
>>> `Job`, or `News`? I  really hope there is a better way to achieve this.
>>> Please help me. Thank you.
>>>
>>>
>>> 
>>>  Virus-free.
>>> www.avast.com
>>> 
>>> <#m_-4072898299284482670_CAHSNPWuR7kHn7knMwj=C45t1qvDB4kRCBdE1+8aB-Zh0qeHyDA@mail.gmail.com_m_-8239736330560799881_DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>>
>>
>> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d0ba3060-a7ae-4837-9d23-c5a652ef6bb5%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHSNPWviFAuAJLS_Mz0ruLnm2321TgV28f-BnSXfScmQ9%3D9jLA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Display objects from different models at the same page according to their published date

2016-06-10 Thread Rafael Guillén
Instead of making them entirely separate models, you can use one model as a 
base and have the other models inherit from them, then you display the base 
model. I think this might be a good fit for multi-table inheritance. See if 
this helps:

https://docs.djangoproject.com/en/1.9/topics/db/models/#model-inheritance


On Friday, June 10, 2016 at 6:59:55 AM UTC-5, Aamu Padi wrote:
>
> This is just a follow up of my question.
>
> I don't want to show each of the model objects separately at the same 
> page. But like feeds of facebook or any other social media. Suppose a new 
> Job object was created, and after that a new News object is created. Then, 
> I want to show the News object first, and then the Job object, and so on.
>
> On Fri, Jun 10, 2016 at 5:12 PM, Aamu Padi  > wrote:
>
>> I have three different models for my app. All are working as I expected. 
>>
>> class Tender(models.Model):
>> title = models.CharField(max_length=256)
>> description = models.TextField()
>> department = models.CharField(max_length=50)
>> address = models.CharField(max_length=50)
>> nature_of_work = models.CharField(choices=WORK_NATURE, 
>> max_length=1)
>> period_of_completion = models.DateField()
>> pubdat = models.DateTimeField(default=timezone.now)
>> 
>> class Job(models.Model):
>> user = models.ForeignKey(settings.AUTH_USER_MODEL)
>> title = models.CharField(max_length=256)
>> qualification = models.CharField(max_length=256)
>> interview_type = models.CharField(max_length=2, 
>> choices=INTERVIEW_TYPE)
>> type_of_job = models.CharField(max_length=1, choices=JOB_TYPE)
>> number_of_vacancies = models.IntegerField()
>> employer = models.CharField(max_length=50)
>> salary = models.IntegerField()
>> pubdat = models.DateTimeField(default=timezone.now)
>> 
>> class News(models.Model):
>> user = models.ForeignKey(settings.AUTH_USER_MODEL)
>> title = models.CharField(max_length=150)
>> body = models.TextField()
>> pubdat = models.DateTimeField(default=timezone.now)
>>
>> Now I am displaying each of them at separate page for each of the model 
>> (e.g. in the *jobs* page, I am displaying only the jobs.). But now at the 
>> home page, I want to display these according to their published date at the 
>> same page. How can I display different objects from different models at the 
>> same page? Do I make a separate model e.g. `class Post` and then use signal 
>> to create a new post whenever a new object is created from `Tender`, or 
>> `Job`, or `News`? I  really hope there is a better way to achieve this. 
>> Please help me. Thank you.
>>
>>
>> 
>>  Virus-free. 
>> www.avast.com 
>> 
>>  
>> <#CAHSNPWuR7kHn7knMwj=C45t1qvDB4kRCBdE1+8aB-Zh0qeHyDA@mail.gmail.com_m_-8239736330560799881_DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d0ba3060-a7ae-4837-9d23-c5a652ef6bb5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django and jQuery, I don't get it

2016-06-10 Thread Stephen J. Butler
Specifically, this style is called an Immediately Invoked Function
Expression, or IIFE.

https://en.wikipedia.org/wiki/Immediately-invoked_function_expression

On Fri, Jun 10, 2016 at 3:36 AM, ludovic coues  wrote:

> > (function($) {
> > 'use strict';
> > 
> > })(django.jQuery);
>
> This syntax is called a closure. First you declare a function so you
> don't contaminate the global scope with your local declared variable.
> Then you execute your function.
> I will assume django.JQuery is the version of JQuery shipped with
> django. Inside the closure, you can refer to it as simply the variable
> $.
>
> I hope that help you.
>
> 2016-06-09 17:06 GMT+02:00 Olivier Dalang :
> > Hi !
> >
> > I'm using several modules that rely on jQuery, and have some own needs as
> > well :
> >
> >> - admin
> >> - grappelli
> >> - autocomplete light
> >> - session security
> >> ...
> >
> >
> > I also see that there are tons of different variables that reference
> jQuery,
> > defined by theses modules, some of which are the same, and some of which
> are
> > not :
> >
> >> $
> >> jQuery
> >> django.jQuery
> >> grp.jQuery
> >> yl.jQuery
> >> ...
> >
> >
> > I also see django uses this type of syntax which seems to deal about
> > dependecies and clonflicts, but is very cryptic to me (unfortunately
> such a
> > problem is very hard to google) :
> >
> >> /*global DateTimeShortcuts, SelectFilter*/
> >> ...
> >> (function($) {
> >> 'use strict';
> >> 
> >> })(django.jQuery);
> >
> >
> >
> > Being a javascript ignorant, up to now, each time I had some javascript
> > exceptions because of jQuery conflicts/undefined, I hacked a bit randomly
> > until the exception disappeared, but I never understood the logic behind
> > this.
> >
> > I'd love some guidance, as my project grows more and more complex, and
> > hacking randomly doesn't shine as a particularly good long term strategy.
> >
> > As partical example, what would be a clean way to add jQuery.AreYouSure
> to
> > the django admin forms ?
> >
> > Is there some documentation or guidelines that explain best practices ?
> Or
> > is it indeed a mess and not just me not understanding ?
> >
> > Thanks !
> >
> > Olivier
> >
> >
> > --
> > 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 https://groups.google.com/group/django-users.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/django-users/CAExk7p2eggp9rTviqo%2BQ%3DUhprxoLPJ4kWeP7Z_sx0xjZY%3DSVqA%40mail.gmail.com
> .
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
>
> Cordialement, Coues Ludovic
> +336 148 743 42
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAEuG%2BTYyB381an2TNW4OiLg3dxfpz0zfcJ4L2D_FxucbKRJ8ZA%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD4ANxWTY3%2BaADijByKcdQGafCa%2BxBegMvcCpt5uAtaPWCNxDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Stuck on tutorial your first Django app part 2

2016-06-10 Thread Neil Hunt
I just went through the tutorial again to check what the definition of my 
__str__() method was and I noticed where the tutorial says to add a custom 
method to polls/models.py. Before I copied and pasted a whole new object 
and method to the file instead of adding the custom method to the object. 
The next bit works now, hurray. Sorry to ask such a stupid question. Thanks 
a lot for your speedy reply.

On Thursday, June 9, 2016 at 10:03:18 PM UTC+1, ke1g wrote:
>
> What is the definition of your __str__() method?
>
> On Thu, Jun 9, 2016 at 4:11 PM, Neil Hunt 
> > wrote:
>
>> Hello,
>>
>> I'm enjoying the tutorial and now I'm stuck on the second page (writing 
>> your first Django app part 2), shortly after this paragraph.
>>
>> 'It’s important to add __str__() 
>> 
>>  
>> methods to your models, not only for your own convenience when dealing with 
>> the interactive prompt, but also because objects’ representations are used 
>> throughout Django’s automatically-generated admin.'
>>
>> The tutorial says to go into the interactive shell again.
>>
>> This line runs without error.
>>
>> 'from polls.models import Question, Choice'
>>
>> The next line Question.objects.all() results in
>>
>> '[]' instead of 
>>
>> '[]'
>>
>> Any help would be much appreciated.
>>
>> -- 
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/3154675a-5749-434e-9fce-3aae49014959%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6cfb84a1-8483-4d2b-bfbe-b90d990746e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


GenericRelations admin form inline

2016-06-10 Thread sunit
I am using django 1.8.4 and i have following model

class Book(models.Model):
title = models.CharField(max_length=100)

class Article(models.Model):
title = models.CharField(max_length=100)

class Paper(models.Model):
title = models.CharField(max_length=100)

class Rating(models.Model):
#Generic foreign key
content_type =models.ForeignKey(ContentType,  blank=True, null=True)
object_id = models.PositiveIntegerField()
object = GenericForeignKey('content_type', 'object_id')
rate = models.CharField(max_length=2, choices=RATING_CHOICES)

Where Rating has a generic key which can be linked to Paper, Article or 
Book.

I want django admin to display inline form where i can edit Rating so i can 
add Rating record and either Book or Paper or Article in a single form.
But i m unable to do. I tried GenericTabularInline but i *want that user 
must be able to choose whether he wants to add book, paper or article to 
the rating record with some choice field on a single form in django admin*. 
I tried read document but it is not helping plss need help.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a6148d18-9275-4bdf-818f-1a60d266dd28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Display objects from different models at the same page according to their published date

2016-06-10 Thread Aamu Padi
This is just a follow up of my question.

I don't want to show each of the model objects separately at the same page.
But like feeds of facebook or any other social media. Suppose a new Job
object was created, and after that a new News object is created. Then, I
want to show the News object first, and then the Job object, and so on.

On Fri, Jun 10, 2016 at 5:12 PM, Aamu Padi  wrote:

> I have three different models for my app. All are working as I expected.
>
> class Tender(models.Model):
> title = models.CharField(max_length=256)
> description = models.TextField()
> department = models.CharField(max_length=50)
> address = models.CharField(max_length=50)
> nature_of_work = models.CharField(choices=WORK_NATURE,
> max_length=1)
> period_of_completion = models.DateField()
> pubdat = models.DateTimeField(default=timezone.now)
>
> class Job(models.Model):
> user = models.ForeignKey(settings.AUTH_USER_MODEL)
> title = models.CharField(max_length=256)
> qualification = models.CharField(max_length=256)
> interview_type = models.CharField(max_length=2,
> choices=INTERVIEW_TYPE)
> type_of_job = models.CharField(max_length=1, choices=JOB_TYPE)
> number_of_vacancies = models.IntegerField()
> employer = models.CharField(max_length=50)
> salary = models.IntegerField()
> pubdat = models.DateTimeField(default=timezone.now)
>
> class News(models.Model):
> user = models.ForeignKey(settings.AUTH_USER_MODEL)
> title = models.CharField(max_length=150)
> body = models.TextField()
> pubdat = models.DateTimeField(default=timezone.now)
>
> Now I am displaying each of them at separate page for each of the model
> (e.g. in the *jobs* page, I am displaying only the jobs.). But now at the
> home page, I want to display these according to their published date at the
> same page. How can I display different objects from different models at the
> same page? Do I make a separate model e.g. `class Post` and then use signal
> to create a new post whenever a new object is created from `Tender`, or
> `Job`, or `News`? I  really hope there is a better way to achieve this.
> Please help me. Thank you.
>
>
> 
>  Virus-free.
> www.avast.com
> 
> <#m_-8239736330560799881_DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHSNPWuR7kHn7knMwj%3DC45t1qvDB4kRCBdE1%2B8aB-Zh0qeHyDA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Display objects from different models at the same page according to their published date

2016-06-10 Thread Aamu Padi
I have three different models for my app. All are working as I expected.

class Tender(models.Model):
title = models.CharField(max_length=256)
description = models.TextField()
department = models.CharField(max_length=50)
address = models.CharField(max_length=50)
nature_of_work = models.CharField(choices=WORK_NATURE, max_length=1)
period_of_completion = models.DateField()
pubdat = models.DateTimeField(default=timezone.now)

class Job(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL)
title = models.CharField(max_length=256)
qualification = models.CharField(max_length=256)
interview_type = models.CharField(max_length=2,
choices=INTERVIEW_TYPE)
type_of_job = models.CharField(max_length=1, choices=JOB_TYPE)
number_of_vacancies = models.IntegerField()
employer = models.CharField(max_length=50)
salary = models.IntegerField()
pubdat = models.DateTimeField(default=timezone.now)

class News(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL)
title = models.CharField(max_length=150)
body = models.TextField()
pubdat = models.DateTimeField(default=timezone.now)

Now I am displaying each of them at separate page for each of the model
(e.g. in the *jobs* page, I am displaying only the jobs.). But now at the
home page, I want to display these according to their published date at the
same page. How can I display different objects from different models at the
same page? Do I make a separate model e.g. `class Post` and then use signal
to create a new post whenever a new object is created from `Tender`, or
`Job`, or `News`? I  really hope there is a better way to achieve this.
Please help me. Thank you.


Virus-free.
www.avast.com

<#DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHSNPWt%2BwkXBSxPr-O%3DWsCNJRfLK0EOUoji3nS%2BdMOWa3x5jDw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django query returns nothing for legacy databse

2016-06-10 Thread Galil
@Gagaro, thanks! That worked for me!

@Remco Gerlich, no I don't have a database router as what I am doing now is 
very simple But thank you for you answer anyway!

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/da7ee48f-c11d-4020-9484-87630b808801%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to forbidden mouse click and keyboard typing when loading page after press submit button in django web?

2016-06-10 Thread Sergiy Khohlov
nothing to do 
Simple way is adding unique ID to the request and use it to server request:
Example :
1) User get  page with id 1
2) User send data  to server using id 1
3) Server send answer with ok and next ID 2

 In case of multiple POST only  first with ID1 is server, other request is
send to /dev/null

Many thanks,

Serge


+380 636150445
skype: skhohlov

On Fri, Jun 10, 2016 at 10:30 AM, meInvent bbird 
wrote:

> sorry for wrong post because i am not familiar with javascript to deal
> with this problem
> i just afraid user crazily press refresh button multiple times or ctr + r
> multiple time during page loading
>
> On Friday, June 10, 2016 at 2:28:09 PM UTC+8, Sergiy Khohlov wrote:
>>
>> This is not django question. Let's imagine. User has pressed submit.
>> Browser is forming request and data is passing to web app. Has web aapp
>> informed about user typing? Of course no. Simple redirect makes forgotting
>> filled form.
>> 10 черв. 2016 04:36 "meInvent bbird"  пише:
>>
>>> how to forbidden mouse click and keyboard typing when loading page after
>>> press submit button in django web?
>>>
>>> --
>>> 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 https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/792a83c6-500a-4443-8c2b-e1a0cb7ae661%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4d0d85e5-0734-41eb-bb3a-ea0ab828d386%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADTRxJMGLpd%3DJOEJT2j%2BbbtotNB56GUTGsDMrdMumpxzUFTVtg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django and jQuery, I don't get it

2016-06-10 Thread ludovic coues
> (function($) {
> 'use strict';
> 
> })(django.jQuery);

This syntax is called a closure. First you declare a function so you
don't contaminate the global scope with your local declared variable.
Then you execute your function.
I will assume django.JQuery is the version of JQuery shipped with
django. Inside the closure, you can refer to it as simply the variable
$.

I hope that help you.

2016-06-09 17:06 GMT+02:00 Olivier Dalang :
> Hi !
>
> I'm using several modules that rely on jQuery, and have some own needs as
> well :
>
>> - admin
>> - grappelli
>> - autocomplete light
>> - session security
>> ...
>
>
> I also see that there are tons of different variables that reference jQuery,
> defined by theses modules, some of which are the same, and some of which are
> not :
>
>> $
>> jQuery
>> django.jQuery
>> grp.jQuery
>> yl.jQuery
>> ...
>
>
> I also see django uses this type of syntax which seems to deal about
> dependecies and clonflicts, but is very cryptic to me (unfortunately such a
> problem is very hard to google) :
>
>> /*global DateTimeShortcuts, SelectFilter*/
>> ...
>> (function($) {
>> 'use strict';
>> 
>> })(django.jQuery);
>
>
>
> Being a javascript ignorant, up to now, each time I had some javascript
> exceptions because of jQuery conflicts/undefined, I hacked a bit randomly
> until the exception disappeared, but I never understood the logic behind
> this.
>
> I'd love some guidance, as my project grows more and more complex, and
> hacking randomly doesn't shine as a particularly good long term strategy.
>
> As partical example, what would be a clean way to add jQuery.AreYouSure to
> the django admin forms ?
>
> Is there some documentation or guidelines that explain best practices ? Or
> is it indeed a mess and not just me not understanding ?
>
> Thanks !
>
> Olivier
>
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAExk7p2eggp9rTviqo%2BQ%3DUhprxoLPJ4kWeP7Z_sx0xjZY%3DSVqA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEuG%2BTYyB381an2TNW4OiLg3dxfpz0zfcJ4L2D_FxucbKRJ8ZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: FieldDoesNotExist during custom migration

2016-06-10 Thread Gagaro
The issue was with my model which had a unique_together with the field 
removed in it. Fixed migrations are:

class Migration(migrations.Migration):

operations = [
migrations.AddField(
model_name='Rendition',
name='filter2',
field=models.CharField(max_length=255, db_index=True),
),
migrations.RunPython(forwards_data_migration, reverse_data_migration
),
migrations.AlterUniqueTogether('rendition', set([])),
migrations.RemoveField(model_name='Rendition', name='filter'),
migrations.DeleteModel('Filter'),
migrations.RenameField(model_name='Rendition', old_name='filter2', 
new_name='filter'),
migrations.AlterUniqueTogether('rendition', set([('image', 'filter', 
'focal_point_key')])),
]




On Wednesday, 8 June 2016 11:32:48 UTC+2, Gagaro wrote:
>
> Hello,
>
> I'm trying to make a migration to change a field ("filter") from a 
> ForeignKey to a CharField. The migration is as follow :
>
> class Migration(migrations.Migration):
>
> operations = [
> migrations.AddField(
> model_name='Rendition',
> name='filter2',
> field=models.CharField(max_length=255, db_index=True),
> ),
> migrations.RunPython(forwards_data_migration, 
> reverse_data_migration),
> migrations.RemoveField(model_name='Rendition', name='filter'),
> migrations.DeleteModel('Filter'),
> migrations.RenameField(model_name='Rendition', old_name='filter2', 
> new_name='filter'),
> ]
>
> When running the migration, I have the following error:
>
> django.core.exceptions.FieldDoesNotExist: Rendition has no field named 
>> u'filter'
>>
>
> The error happens  during the RemoveField (migrations.RemoveField(
> model_name='Rendition', name='filter')).
>
> So, a couple questions:
>
> * Is there a better way to change a field type (with data migration)?
> * Why do I have this error, when my field is present?
>
> The migration can be found there: 
> https://github.com/Gagaro/wagtail/blob/02f4804b49d6f8b65ffb193d7a0dfc7872d323bd/wagtail/wagtailimages/migrations/0014_remove_filter_model.py
> And the relevant model is there: 
> https://github.com/Gagaro/wagtail/blob/02f4804b49d6f8b65ffb193d7a0dfc7872d323bd/wagtail/wagtailimages/models.py#L458-L516
>
> Thanks
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4392e219-bc7a-40c9-879c-00ce7c314829%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to forbidden mouse click and keyboard typing when loading page after press submit button in django web?

2016-06-10 Thread meInvent bbird
sorry for wrong post because i am not familiar with javascript to deal with 
this problem 
i just afraid user crazily press refresh button multiple times or ctr + r 
multiple time during page loading 

On Friday, June 10, 2016 at 2:28:09 PM UTC+8, Sergiy Khohlov wrote:
>
> This is not django question. Let's imagine. User has pressed submit. 
> Browser is forming request and data is passing to web app. Has web aapp 
> informed about user typing? Of course no. Simple redirect makes forgotting 
> filled form.
> 10 черв. 2016 04:36 "meInvent bbird" > 
> пише:
>
>> how to forbidden mouse click and keyboard typing when loading page after 
>> press submit button in django web?
>>
>> -- 
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/792a83c6-500a-4443-8c2b-e1a0cb7ae661%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4d0d85e5-0734-41eb-bb3a-ea0ab828d386%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.