title: Field 'id' expected a number but got <built-in function id>
body: <p>i want to delete and edit notes in my django app, but i am struck on this error for long
  Error : "<strong>TypeError at /delete/1/
  Field 'id' expected a number but got .</strong>"</p>
  
  <p>models.py</p>
  
  <pre><code>from django.db import models
  from django.utils import timezone
  
  # Create your models here.
  class Category(models.Model):
      name = models.CharField(max_length=100)
  
      class Meta:
          verbose_name = ("Category")
          verbose_name_plural = ("Categories")
      def __str__(self):
          return self.name
  
  class ToDoList(models.Model):
      title = models.CharField(max_length=200)
      content = models.CharField(max_length=500)
      created_on = models.DateField(default=timezone.now().strftime("%Y-%m-%d"))
      due_date = models.DateField(default=timezone.now().strftime("%Y-%m-%d"))
      category = models.ForeignKey(Category,on_delete=models.DO_NOTHING,default="general")
  
      class Meta:
        ordering = ["-created_on"]
      def __str__(self):
          return self.title
  
  class Note(models.Model):
      text = models.CharField(max_length=100)
      created = models.DateTimeField(auto_now_add = True)
  
      class Meta:
          verbose_name = ("Note")
      def __str__(self):
          return self.text
  
  </code></pre>
  
  <p>my todoapp/urls.py</p>
  
  <p><strong>urls.py</strong></p>
  
  <pre><code>from django.contrib import admin
  from django.urls import path, include
  from todolist.views import index,note,del_note,edit_note
  
  
  urlpatterns = [
      path('admin/', admin.site.urls),
      path('',index,name = 'ToDoList'),
      #path('',note,name = 'Note'),
      path('note/', note, name='Note'),
      path('delete/&lt;note_id&gt;/',del_note ,name = 'del_note'),
      path('edit/&lt;note_id&gt;/',edit_note,name='edit_note'),
  ]
  
  </code></pre>
  
  <p>my todolist/views
  <strong>views.py</strong></p>
  
  <pre><code>def del_note(request, note_id):
  
      x = Note.objects.get(id = id)
      print (x) // tried for degugging
      x.delete()
      return redirect("/")   
  
  
  def edit_note(request, note_id):
      x = Note.objects.get( id = id)
      print (x)
      return redirect("/")
  </code></pre>
  
  <p>here is my html
  <strong>note.html</strong></p>
  
  <pre><code>&lt;body&gt;
      &lt;nav class="navbar navbar-inverse"&gt;
          &lt;div class="container-fluid"&gt;
              &lt;div class="navbar-header"&gt;
                  &lt;a class="navbar-brand" href="#"&gt;ToDo/Notes&lt;/a&gt;
              &lt;/div&gt;
              &lt;ul class="nav navbar-nav"&gt;
                  &lt;li&gt;&lt;a href="{% url 'ToDoList' %}"&gt;ToDoApp&lt;/a&gt;&lt;/li&gt;
                  &lt;li class="active"&gt;&lt;a href="{% url 'Note' %}"&gt;Notes&lt;/a&gt;&lt;/li&gt;
  
              &lt;/ul&gt;
          &lt;/div&gt;
      &lt;/nav&gt;
  
      &lt;div class="container"&gt;
          &lt;div class="content"&gt;
              &lt;h1&gt;Notes&lt;/h1&gt;
              &lt;p class="tagline"&gt;a Django Notes app&lt;/p&gt;
              &lt;form action="" method="POST"&gt;
                  {% csrf_token %}
                  &lt;div class="inputContainer"&gt;
                      {{ form.as_p }}
                      &lt;input type="submit" placeholder="Add a Note" value="Add note"&gt;
                  &lt;/div&gt;
              &lt;/form&gt;
  
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;section class="section"&gt;
          &lt;div class="container"&gt;
              &lt;div class="row"&gt;
  
                  {% for sticky in Notes %}
                  &lt;div class="col-md-3"&gt;
                      &lt;div class="box"&gt;
                          &lt;article class="media"&gt;
                              &lt;div class="media-left"&gt;
                                  &lt;a href="{% url 'edit_note' sticky.id %}"
                                      &lt;button class="glyphicon glyphicon-pencil"&gt;
  
                                      &lt;/button&gt;
                                  &lt;/a&gt;
                              &lt;/div&gt;
                              &lt;div class="media-content"&gt;
                                  &lt;div class="content"&gt;
                                      &lt;ul&gt;
  
                                          &lt;li&gt;
                                              &lt;p&gt;{{sticky.text}}&lt;/p&gt;
                                          &lt;/li&gt;
  
                                      &lt;/ul&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                              &lt;div class="media-right"&gt;
                                  &lt;a href="{% url 'del_note' sticky.id %}"
                                                      &lt;button class="delete"&gt;&lt;/button&gt;
                                                      &lt;/a&gt;
                              &lt;/div&gt;
                          &lt;/article&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  {% endfor %}
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/section&gt;
  &lt;/body&gt;
  
  </code></pre>
  
  <p>migration file
  <strong>0001_intial.py</strong></p>
  
  <pre><code># Generated by Django 3.0.3 on 2020-03-28 06:07
  
  from django.db import migrations, models
  import django.db.models.deletion
  
  
  class Migration(migrations.Migration):
  
      initial = True
  
      dependencies = [
      ]
  
      operations = [
          migrations.CreateModel(
              name='Category',
              fields=[
                  ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                  ('name', models.CharField(max_length=100)),
              ],
              options={
                  'verbose_name': 'Category',
                  'verbose_name_plural': 'Categories',
              },
          ),
          migrations.CreateModel(
              name='Note',
              fields=[
                  ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                  ('text', models.CharField(max_length=100)),
                  ('created', models.DateTimeField(auto_now_add=True)),
              ],
              options={
                  'verbose_name': 'Note',
              },
          ),
          migrations.CreateModel(
              name='ToDoList',
              fields=[
                  ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                  ('title', models.CharField(max_length=200)),
                  ('content', models.CharField(max_length=500)),
                  ('created_on', models.DateField(default='2020-03-28')),
                  ('due_date', models.DateField(default='2020-03-28')),
                  ('category', models.ForeignKey(default='general', on_delete=django.db.models.deletion.DO_NOTHING, to='todolist.Category')),
              ],
              options={
                  'ordering': ['-created_on'],
              },
          ),
      ]
  
  </code></pre>
  
  <p>here is my note app page 
  <a href="https://i.stack.imgur.com/rqp82.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rqp82.png" alt="enter image description here"></a></p>
  
  <p>so when i click on delete note i get below error
  <a href="https://i.stack.imgur.com/y5jb3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y5jb3.png" alt="enter image description here"></a></p>
  
  <p>could you please give idea about how to perform edit_note operation to edit my note as well, Thanks in advance.</p>