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 <aamu...@gmail.com 
> <javascript:>> 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.
>>
>>
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
>>  Virus-free. 
>> www.avast.com 
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
>>  
>> <#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.

Reply via email to