I am getting the following error in my Django blog app project "‘Exception Type: NoReverseMatch at /
Exception Value: Reverse for ‘update_profile_picture’ not found. ‘update_profile_picture’ is not a valid view function or pattern name.
"’. Here is the error line "'<a class="navbar-brand p-3 {% if request.path == request.user.get_absolute_url %}active{% endif %}" href="{{ request.user.get_absolute_url }}">Update Profile Picture</a>"'
. Can someone please assist?
Couple different notes here.
When posting code or templates, a single line or partial line of code can be enclosed by single backtick characters - ` to ensure the forum software doesn’t try to interpret it.
We’re going to need to see more of this template - especially any tags containing the string update_profile_picture
. We’ll also need to see the view that is causing this error, and your urls.py definition that contains a named entry for update_profile_picture
.
Here are the codes;
# models.py
class CustomUser(AbstractUser):
profile_picture = models.ImageField(upload_to='profile_pictures/', blank=True, null=True)
def get_absolute_url(self):
return reverse('update_profile_picture'),
#views.py
@login_required
def update_profile_picture(request):
if request.method == 'POST':
form = ProfilePictureForm(request.POST, request.FILES, instance=request.user)
if form.is_valid():
form.save()
return redirect('profile') # Redirect to the profile page
else:
form = ProfilePictureForm(instance=request.user)
return render(request, 'update_profile_picture.html', {'form': form}),
#url.py
path('update-profile-picture/', views.update_profile_picture, name='update_profile_picture'),
# update_profile_picture.html
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Save</button>
</form>
# base.html
<a class="navbar-brand p-3 {% if request.path == request.user.get_absolute_url %}active{% endif %}" href="{{ request.user.get_absolute_url }}">Update Profile Picture</a>
# admin.py
from django.contrib import admin
from .models import Post, Attachment
from django.contrib.auth import get_user_model
CustomUser = get_user_model()
class PostAdmin(admin.ModelAdmin):
list_display = ('title', 'content', 'date_created', 'slug', 'author_username', 'status')
def author_username(self, obj):
return obj.author.username
author_username.short_description = 'Author Username'
admin.site.register(Post, PostAdmin)
admin.site.register(Attachment)
# settings.py
AUTH_USER_MODEL = 'blog.CustomUser'
Side note #1: Generally speaking, you want your get_absolute_url
to identify a particular instance of the model. Reversing a static url is going to generate the same url for everyone. See the docs and examples at get_absolute_url
Side note #2: When fencing off blocks of code, you use three backtick - ` characters on lines by themselves. (They can’t be parts of existing lines.) This means you’ll have a line of ```, then the code for a file, then another line of ```. (I’ve taken the liberty of fixing this post for you.)
Please post the complete error message you are receiving, along with the traceback.
Here is the error message ’ Error during template rendering
In template C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\blog\templates\blog\base.html
, error at line 102
Reverse for ‘update_profile_picture’ not found. ‘update_profile_picture’ is not a valid view function or pattern name.’ the trace 'Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 4.2.1
Python Version: 3.11.4
Installed Applications:
[‘blog’,
‘translator’,
‘accounts’,
‘bootstrap5’,
‘django.contrib.contenttypes’,
‘django.contrib.admin’,
‘django.contrib.auth’,
‘django.contrib.sessions’,
‘django.contrib.messages’,
‘django.contrib.staticfiles’,
‘django_extensions’]
Installed Middleware:
[‘django.middleware.security.SecurityMiddleware’,
‘django.contrib.sessions.middleware.SessionMiddleware’,
‘django.middleware.common.CommonMiddleware’,
‘django.middleware.csrf.CsrfViewMiddleware’,
‘django.contrib.auth.middleware.AuthenticationMiddleware’,
‘django.contrib.messages.middleware.MessageMiddleware’,
‘django.middleware.clickjacking.XFrameOptionsMiddleware’,
‘debug_toolbar.middleware.DebugToolbarMiddleware’]
Template error:
In template C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\blog\templates\blog\base.html, error at line 102
Reverse for ‘update_profile_picture’ not found. ‘update_profile_picture’ is not a valid view function or pattern name.
92 : Register
93 :
94 :
95 :
96 : {% if post %}
97 : Delete Post
98 : {% endif %}
99 :
100 :
101 :
102 : Update Profile Picture
103 :
104 :
105 :
106 :
107 : My View
108 :
109 :
110 :
111 : {% if user.is_authenticated %}
112 :
Traceback (most recent call last):
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\core\handlers\exception.py”, line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\core\handlers\base.py”, line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\blog\views.py”, line 23, in index_view
return render(request, ‘blog/index_view.html’, {‘user’: user})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\shortcuts.py”, line 24, in render
content = loader.render_to_string(template_name, context, request, using=using)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\template\loader.py”, line 62, in render_to_string
return template.render(context, request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\template\backends\django.py”, line 61, in render
return self.template.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\template\base.py”, line 175, in render
return self._render(context)
^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\template\base.py”, line 167, in _render
return self.nodelist.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\template\base.py”, line 1005, in render
return SafeString(“”.join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\template\base.py”, line 1005, in
return SafeString(“”.join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\template\base.py”, line 966, in render_annotated
return self.render(context)
^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\template\loader_tags.py”, line 157, in render
return compiled_parent._render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\template\base.py”, line 167, in _render
return self.nodelist.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\template\base.py”, line 1005, in render
return SafeString(“”.join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\template\base.py”, line 1005, in
return SafeString(“”.join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\template\base.py”, line 966, in render_annotated
return self.render(context)
^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\template\base.py”, line 1064, in render
output = self.filter_expression.resolve(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\template\base.py”, line 715, in resolve
obj = self.var.resolve(context)
^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\template\base.py”, line 847, in resolve
value = self._resolve_lookup(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\template\base.py”, line 914, in _resolve_lookup
current = current()
^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\blog\models.py”, line 19, in get_absolute_url
return reverse(‘update_profile_picture’)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\urls\base.py”, line 88, in reverse
return resolver._reverse_with_prefix(view, prefix, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\urls\resolvers.py”, line 828, in _reverse_with_prefix
raise NoReverseMatch(msg)
^^^^^^^^^^^^^^^^^^^^^^^^^
Exception Type: NoReverseMatch at /
Exception Value: Reverse for ‘update_profile_picture’ not found. ‘update_profile_picture’ is not a valid view function or pattern name.', and the error line ‘Update Profile Picture’
You posted this snippet above showing this definition for the url:
#url.py
path('update-profile-picture/', views.update_profile_picture, name='update_profile_picture'),
Do you have an app_name
setting in this urls.py file?
Is this from your root urls.py file, or from a urls.py file in your blogs
app?
If it’s in your blogs
app, are you including this urls.py
file in your root urls.py
file?
(It might be easier at this point if you posted both complete urls.py files.)
Here are thye urls.py files
# root urls.py
from django.contrib import admin
from django.urls import path, include
from django.views.generic.base import RedirectView
from django.contrib.staticfiles.storage import staticfiles_storage
from blog import urls as blog_urls
from translator import urls as translator_urls
from accounts import urls as accounts_urls
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
urlpatterns = [
path('admin/', admin.site.urls),
path('', include(blog_urls)),
path('translator/', include(translator_urls)),
path('accounts/', include(accounts_urls)),
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# blog urls.py
from django.urls import path
from . import view
app_name = 'blog'
urlpatterns = [
path('', views.index_view, name='index_view'),
path('base_view/', views.base_view, name = 'base_view'),
#URL pattern for the list of posts
path('posts/', views.post_list, name='post_list'),
# URL pattern for viewing a single post
path('post/<slug:slug>/', views.post_detail, name='post_detail'),
path('template_list/', views.template_list, name='template_list'),
path('create/', views.create_post, name='create_post'),
path('<slug:slug>/edit/', views.post_edit, name='post_edit'),
# last edited urls by addind views
path('post/<int:pk>/delete/', views.PostDeleteView.as_view(), name='post_delete'),
path('my-view/', views.my_view, name='my_view'),
path('update-profile-picture/', views.update_profile_picture, name='update_profile_picture'),
]
Side note: The ``` must be lines by themselves. They can’t be parts of other lines.
So, this:
defines a namespace for these URLs.
That means you need to reference these URLs specifying that namespace.
In this case, then it would be blog:update_profile_picture
.
Do you mean ‘blog:update_profile_picture’ in the views function?
This applies at any point where you’re trying to use it in a reverse
type situation. This includes when being used in templates, models, forms, or any other code.
Thanks so much for your observations and corrections. I have been able to resolve that error by referencing the blog in the URL of the base html.
I get the following error messges if I click on the ‘Update Profile Picture’ page. " TemplateDoesNotExist at /update_profile_picture/
update_profile_picture.html"
Please post the complete error message with traceback, the view that is rendering this page, your TEMPLATES
setting, and identify the directory containing your update_profile_picture.html
.
Here are the error messages, the codes and the template path ’ TemplateDoesNotExist at /update-profile-picture/
update_profile_picture.html’
’ Template-loader postmortem
Django tried loading these templates, in this order:
Using engine django
:
django.template.loaders.filesystem.Loader
: C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\templates\update_profile_picture.html (Source does not exist)django.template.loaders.app_directories.Loader
: C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\blog\templates\update_profile_picture.html (Source does not exist)django.template.loaders.app_directories.Loader
: C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\translator\templates\update_profile_picture.html (Source does not exist)django.template.loaders.app_directories.Loader
: C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\accounts\templates\update_profile_picture.html (Source does not exist)django.template.loaders.app_directories.Loader
: C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\bootstrap5\templates\update_profile_picture.html (Source does not exist)django.template.loaders.app_directories.Loader
: C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\contrib\admin\templates\update_profile_picture.html (Source does not exist)django.template.loaders.app_directories.Loader
: C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\contrib\auth\templates\update_profile_picture.html (Source does not exist)django.template.loaders.app_directories.Loader
: C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django_extensions\templates\update_profile_picture.html (Source does not exist)’
'Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/update-profile-picture/
Django Version: 4.2.1
Python Version: 3.11.4
Installed Applications:
[‘blog’,
‘translator’,
‘accounts’,
‘bootstrap5’,
‘django.contrib.contenttypes’,
‘django.contrib.admin’,
‘django.contrib.auth’,
‘django.contrib.sessions’,
‘django.contrib.messages’,
‘django.contrib.staticfiles’,
‘django_extensions’]
Installed Middleware:
[‘django.middleware.security.SecurityMiddleware’,
‘django.contrib.sessions.middleware.SessionMiddleware’,
‘django.middleware.common.CommonMiddleware’,
‘django.middleware.csrf.CsrfViewMiddleware’,
‘django.contrib.auth.middleware.AuthenticationMiddleware’,
‘django.contrib.messages.middleware.MessageMiddleware’,
‘django.middleware.clickjacking.XFrameOptionsMiddleware’,
‘debug_toolbar.middleware.DebugToolbarMiddleware’]
Template loader postmortem
Django tried loading these templates, in this order:
Using engine django:
* django.template.loaders.filesystem.Loader: C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\templates\update_profile_picture.html (Source does not exist)
* django.template.loaders.app_directories.Loader: C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\blog\templates\update_profile_picture.html (Source does not exist)
* django.template.loaders.app_directories.Loader: C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\translator\templates\update_profile_picture.html (Source does not exist)
* django.template.loaders.app_directories.Loader: C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\accounts\templates\update_profile_picture.html (Source does not exist)
* django.template.loaders.app_directories.Loader: C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\bootstrap5\templates\update_profile_picture.html (Source does not exist)
* django.template.loaders.app_directories.Loader: C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\contrib\admin\templates\update_profile_picture.html (Source does not exist)
* django.template.loaders.app_directories.Loader: C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\contrib\auth\templates\update_profile_picture.html (Source does not exist)
* django.template.loaders.app_directories.Loader: C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django_extensions\templates\update_profile_picture.html (Source does not exist)
Traceback (most recent call last):
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\core\handlers\exception.py”, line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\core\handlers\base.py”, line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\contrib\auth\decorators.py”, line 23, in _wrapper_view
return view_func(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\blog\views.py”, line 141, in update_profile_picture
return render(request, ‘update_profile_picture.html’, {‘form’: form})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\shortcuts.py”, line 24, in render
content = loader.render_to_string(template_name, context, request, using=using)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\template\loader.py”, line 61, in render_to_string
template = get_template(template_name, using=using)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\template\loader.py”, line 19, in get_template
raise TemplateDoesNotExist(template_name, chain=chain)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Exception Type: TemplateDoesNotExist at /update-profile-picture/
Exception Value: update_profile_picture.html’
“'def update_profile_picture(request):
if request.method == ‘POST’:
form = ProfilePictureForm(request.POST, request.FILES, instance=request.user)
if form.is_valid():
form.save()
return redirect(‘profile’) # Redirect to the profile page
else:
form = ProfilePictureForm(instance=request.user)
return render(request, ‘update_profile_picture.html’, {‘form’: form})”’
‘TEMPLATES = [
{
‘BACKEND’: ‘django.template.backends.django.DjangoTemplates’,
‘DIRS’: [os.path.join(BASE_DIR,‘templates’)],
‘APP_DIRS’: True,
‘OPTIONS’: {
‘context_processors’: [
‘django.template.context_processors.debug’,
‘django.template.context_processors.request’,
‘django.contrib.auth.context_processors.auth’,
‘django.contrib.messages.context_processors.messages’,
],
},
},
]’
The directory containing my ‘update_profile_picture.html’ is as follows; Project/blog/templates/blog/update_profile_picture.html
You have:
but you have:
Your template is stored within the blog
directory inside your templates
directory. You need to specify the blog
directory as part of the template name for it to be found.
See the explanations and examples at Writing your first Django app, part 3 | Django documentation | Django
Thank you so mech for your observation, the error has been resolved
I get the following error messages if I want to register a new user to my blog app. Can someone kindly assist? ’ AttributeError at /accounts/register/
Manager isn’t available; ‘auth.User’ has been swapped for ‘blog.CustomUser’
Request Method: | POST |
---|---|
Request URL: | http://127.0.0.1:8000/accounts/register/ |
Django Version: | 4.2.1 |
Exception Type: | AttributeError |
Exception Value: | Manager isn’t available; ‘auth.User’ has been swapped for ‘blog.CustomUser’ |
Trace back;
'Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/accounts/register/
Django Version: 4.2.1
Python Version: 3.11.4
Installed Applications:
[‘blog’,
‘translator’,
‘accounts’,
‘bootstrap5’,
‘django.contrib.contenttypes’,
‘django.contrib.admin’,
‘django.contrib.auth’,
‘django.contrib.sessions’,
‘django.contrib.messages’,
‘django.contrib.staticfiles’,
‘django_extensions’]
Installed Middleware:
[‘django.middleware.security.SecurityMiddleware’,
‘django.contrib.sessions.middleware.SessionMiddleware’,
‘django.middleware.common.CommonMiddleware’,
‘django.middleware.csrf.CsrfViewMiddleware’,
‘django.contrib.auth.middleware.AuthenticationMiddleware’,
‘django.contrib.messages.middleware.MessageMiddleware’,
‘django.middleware.clickjacking.XFrameOptionsMiddleware’,
‘debug_toolbar.middleware.DebugToolbarMiddleware’]
Traceback (most recent call last):
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\core\handlers\exception.py”, line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\core\handlers\base.py”, line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\accounts\views.py”, line 15, in register
if form.is_valid():
^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\forms\forms.py”, line 201, in is_valid
return self.is_bound and not self.errors
^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\forms\forms.py”, line 196, in errors
self.full_clean()
^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\forms\forms.py”, line 433, in full_clean
self._clean_fields()
^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\forms\forms.py”, line 448, in clean_fields
value = getattr(self, "clean%s" % name)()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\contrib\auth\forms.py”, line 155, in clean_username
and self._meta.model.objects.filter(username__iexact=username).exists()
^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\Casimir ABIRIYI\BlogAndTranslatorApp\venv\Lib\site-packages\django\db\models\manager.py”, line 196, in get
raise AttributeError(
^
Exception Type: AttributeError at /accounts/register/
Exception Value: Manager isn’t available; ‘auth.User’ has been swapped for ‘blog.CustomUser’’
Please post the view that /accounts/register/
will execute.
Side note: When posting code, templates, or error messages here, remember to enclose the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted.
I think I have realized because of your response that since I have changed from the User model to the CustomUser model, I need to create views, URLs, forms and templates for the accounts app. I will do that and if I have any error, I will let you know. Thanks.
No, that is not necessarily true. If your answer here is saying that you’re relying upon the system-provided views, then that’s ok - it just raises a different line of questions.