# TypeError- edit() missing 1 required positional argument: ‘title’

**URL:** <https://forum.djangoproject.com/t/typeerror-edit-missing-1-required-positional-argument-title/3899>\
**Category:** Using Django\
**Created:** [August 15, 2020, 10:25am UTC](https://forum.djangoproject.com/t/typeerror-edit-missing-1-required-positional-argument-title/3899 "2020-08-15T10:25:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gunaratna](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/gunaratna/32/1900_2.png) [@gunaratna](https://forum.djangoproject.com/u/gunaratna)\
**Post date:** [August 15, 2020, 10:25am UTC](https://forum.djangoproject.com/t/typeerror-edit-missing-1-required-positional-argument-title/3899/1 "2020-08-15T10:25:39Z")

</div>

I am getting TypeError. Can someone help me,please?

HTML info:

```
{% csrf_token %}

<div>{{Content|safe}}</div>

<input type="submit" value="Edit">

```

URLS.py  
path(“edit”,views.edit,name=“edit”),

Views  
def edit(request,title):

```
if request.method == 'POST':

    x = markdowner.convert(util.get_entry(title))        
    form = CreateForm(initial={'Content': x})
    return render(request,"encyclopedia/edit.html",{"form":form,"title": title})
```

---

<div class="post-metadata">

**Author:** ![datalowe](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/datalowe/32/2360_2.png) [@datalowe](https://forum.djangoproject.com/u/datalowe)\
**Post date:** [August 15, 2020, 11:00am UTC](https://forum.djangoproject.com/t/typeerror-edit-missing-1-required-positional-argument-title/3899/2 "2020-08-15T11:00:13Z")

</div>

Hi,

Could you give some more information about the error you are getting, and the view you use?

At a minimum, please write out the full “TypeError line”, since it usually includes what function/method call failed, e. g. `TypeError: convert() missing 1 required positional argument: 'text'`.

Other relevant questions to answer:

- I’m assuming `markdowner` is an instance of the `MarkDown` class from the [markdown2](https://github.com/trentm/python-markdown2) package? It’s not a good thing that others need to guess this though, it’s far better if you explain your code and/or include import statements that make this clear.

- What is `util.get_entry`? Is it a self-written function? It’s probably best if you paste what you have in `util.py` then (assuming `util` is a module/script, rather than an object).

- In your view’s code, the context you use makes use of a `title` variable. What is that?

- Your template seems to refer to a `Content` variable, but there is no such key in the context dictionary (`{"form":form,"title": title}`) used in your view’s code. Do you perhaps instead want to render your form, e. g. `form.as_p`?

- What is it that you want the template to do? Converting markdown into template tags and then feeding that into your form is unusual so the reason for doing so needs to be explained.

In order for others to be able to help, you need to explain what you seek to do, what you (your code) are actually doing right now, and in some detail what it is that goes wrong. It’s tricky to know exactly how to describe those things, or to know what’s relevant or not, but it’s a very valuable skill and crucial for getting help and/or collaborating with others.

---

<div class="post-metadata">

**Author:** ![gunaratna](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/gunaratna/32/1900_2.png) [@gunaratna](https://forum.djangoproject.com/u/gunaratna)\
**Post date:** [August 15, 2020, 11:14am UTC](https://forum.djangoproject.com/t/typeerror-edit-missing-1-required-positional-argument-title/3899/3 "2020-08-15T11:14:30Z")

</div>

TypeError- edit() missing 1 required positional argument: ‘title’

In above code,  
`markdowner` is an instance of the `MarkDown` class from the [markdown2](https://github.com/trentm/python-markdown2) package.

util.get\_entry(variable) is a function which returns contents based on the variable(‘title’) value.

Following are imports in View.py  
from django.shortcuts import render

from . import util

from django.urls import reverse

from django.http import HttpResponseRedirect

from markdown2 import Markdown

from django import forms

from django.http import HttpResponse

from django.http import request

In the HTML template, when use click ‘Edit’ button, the page should allow the user to edit the content of the page. However, now the page itself is not displaying due to error.

---

<div class="post-metadata">

**Author:** ![datalowe](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/datalowe/32/2360_2.png) [@datalowe](https://forum.djangoproject.com/u/datalowe)\
**Post date:** [August 15, 2020, 12:13pm UTC](https://forum.djangoproject.com/t/typeerror-edit-missing-1-required-positional-argument-title/3899/4 "2020-08-15T12:13:26Z")

</div>

OK, so for the error you’re getting, it’s apparent now that you wrote out the full `TypeError` what is causing that error.

In your urls.py file you have `path(“edit”,views.edit,name=“edit”),`. Your function definition reads `def edit(request,title)`. The `edit` function is expecting to be passed a `title` value. You probably want to change your URL path so that it uses a path converter, e. g. `path(“<str:title>/edit/”,views.edit,name=“edit”),`. You can read more about [path converters in the Django docs](https://docs.djangoproject.com/en/3.1/topics/http/urls/#path-converters).

Please use ``` backtick characters to enclose your code snippet blocks, or single ` backtick characters for inline code. It really helps readability.

---

<div class="post-metadata">

**Author:** ![gunaratna](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/gunaratna/32/1900_2.png) [@gunaratna](https://forum.djangoproject.com/u/gunaratna)\
**Post date:** [August 15, 2020, 2:36pm UTC](https://forum.djangoproject.com/t/typeerror-edit-missing-1-required-positional-argument-title/3899/5 "2020-08-15T14:36:45Z")

</div>

Thank you so much!  
You saved my days. I spent many hours to try to figure this mistake.  
Thanks a lot,again!
