Hey, Thanks for replying. I tried what you said but It's still giving 
the error. I've also updated the StackOverflow question with updated code.
One more thing, as you said about JavaScript. I think I won't be needing it 
on that page because this *through *models seems to be the solution to my 
problem (once that table error is resolved). Because I think I can manually 
add "fees" through that additional field (by Choosing the university, and 
course from the drop down).




On Tuesday, September 5, 2017 at 3:03:14 AM UTC+5, mark wrote:
>
> I replied to your StackOverflow question. An error in your through model 
> caused the no such table error.
>
> Keep in mind that web pages are only generated once, and then presented to 
> the user. If you want the page to display the cost of the course based on 
> the university you pick on this page in the select box, then you need some 
> javascript to perform a real-time update to your admin page before to 
> display the correct price. There are frameworks available as django apps 
> for doing this.
>
> Mark
>
> On Mon, Sep 4, 2017 at 10:19 AM, Omer Iqbal <omeri...@gmail.com 
> <javascript:>> wrote:
>
>> Hi,
>>
>>
>>
>>
>>
>>
>>
>> Is it possible to add one or more field (Char Field) to the options of 
>> ManyToMany field?
>>
>> My current models result in this:
>>
>> <https://i.stack.imgur.com/Fz1tr.png>
>>
>>
>>
>> *My Models:*
>>
>>
>> class engineeringUni(models.Model):
>>
>>
>>     field2 = models.CharField(max_length=200)
>>     des_eng = models.CharField(max_length=1000, default='Add description'
>> )
>>
>>
>>     def __str__(self):
>>
>>         return self.field2
>>
>>
>>     def description_eng_universities(self):
>>
>>         return self.des_eng
>>
>>
>>
>>
>> class engineering_courses(models.Model):
>>
>>     course_name = models.CharField(max_length=400)
>>
>>     course_description = models.CharField(max_length=1000, default='This 
>> is a description')
>>
>>     course_offered_by = models.ManyToManyField(engineeringUni, 
>> related_name='course_offered_by')
>>
>>     course_duration = models.IntegerField(blank=False, default='2')
>>
>>
>>
>>
>>     def __str__(self):
>>
>>         return self.course_name
>>
>>
>>
>>
>>     def description_course(self):
>>
>>         return self.course_description
>>
>>
>>
>>
>>     def offered_by_courses(self):
>>
>>         return self.course_offered_by
>>
>>
>>
>>
>>     def duration_courses(self):
>>
>>
>>
>>         return str(self.course_duration)
>>
>>
>>
>> As you can see in the image, I have the options in the ManyToMany field. 
>> Those options are:
>>
>>
>>    - University 1
>>    - University 2
>>    - University 3
>>
>>
>>
>> What I want to have is an additional text (Char) field next to each of 
>> these options (University 1, University 2, University 3).
>>
>> Is this possible?
>>
>>
>> I asked this question on StackOverflow (link 
>> <https://stackoverflow.com/questions/46035044/django-adding-more-fields-to-each-manytomany-field-option>)
>>  
>> and through one answer, I became aware of *through* models in ManyToMany 
>> field and on using through models, I get *no such table error*.
>>
>>
>> You might be asking why do I need this? As you can see in the image, my 
>> project (personal project) is about universities etc. What I want is that 
>> If I add a course and then choose a university (from ManyToMany Field), I 
>> should have an option to enter the fees of that course for that particular 
>> university.
>>
>> -- 
>> 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 <javascript:>.
>> To post to this group, send email to django...@googlegroups.com 
>> <javascript:>.
>> 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/f9efd14f-3d82-4032-a425-48d3b0dfaede%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/f9efd14f-3d82-4032-a425-48d3b0dfaede%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> 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/1460ea3c-330a-4a30-b7c1-a34bdc169473%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to