Note that there are some explanatory texts on larger screens.

plurals
  1. POedit and update the row in database using django
    primarykey
    data
    text
    <p>models.py</p> <pre><code>class Author(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=40) email = models.EmailField() age = models.IntegerField() def __unicode__(self): return "{0} {1} {2} {3} {4}".format( self, self.first_name, self.last_name, self.email, self.age) class Book(models.Model): book_name=models.CharField(max_length=30) publisher_name=models.CharField(max_length=40) author=models.ForeignKey(Author) def __unicode__(self): return "{0} {1} {2}".format( self.pk, self.book_name, self.publisher_name) </code></pre> <p>forms.py</p> <pre><code>class AuthorForm(ModelForm): class Meta: model = Author BookFormset = inlineformset_factory(Author, Book, fields=('book_name', 'publisher_name'), extra=1, can_delete=False) </code></pre> <p>urls.py is</p> <pre><code>admin.autodiscover() urlpatterns = patterns('', url('^$', index), url('^index/$', index), url('^addbook/$', addbook), url('^book_detail/$', book_detail, 'book_summary'), url('^editbook/(?P&lt;book_id&gt;\d+)/$', editbook) , url('^deletebook/(?P&lt;book_id&gt;\d+)/$',deletebook) , url(r'^admin/', include(admin.site.urls)), ) </code></pre> <p>I need to perform edit and update the row in database,i did it by using single table.But using two table have some confusion how to take 2nd table using that particular id.I am using forms in this.Can you help me in this to write codes in views.py.Example for doing the same using two table is no where i seen.</p> <p>Thanks </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload