Categories
Mastering Development

django cannot access default admin section

I am trying to access the django default admin section and I get a 404 error “not found” I can access the default django splash page that tells me I am in debugging mode If I try to access via nginx, I get a nginx bases 404 error ‘not found’ in browser but my logs […]

Categories
Mastering Development

Django login and logout not functioning as required

I have a custom user in Django and when I logout the user can still see the main page by going to the url. I do not know which part is incorrect as I am using decorators already. I ave two apps, main and home. this is my urls.py: urlpatterns = [ #Has to be […]

Categories
Mastering Development

I’m new to Django Rest_Framework. I am trying to implement a function-based view but facing problem with the put method

I want to know how to access a particular object given a particular ID, and then update it. I’m currently getting the “405 method not allowed” error. Is it possible to access an object via an ID, as mentioned above, or do I have to approach the problem in a different way? My code is […]

Categories
Development

django.core.exceptions.ImproperlyConfigured: The included URLconf does not appear to have any patterns in it

I have a django 3 app i made following a tutorial. The tutorial was for django 2 but i would like to learn how to do it in django 3. I got this error and i do not understand what to do to correct this error. The error mentions something about a circular import. django.core.exceptions.ImproperlyConfigured: […]

Categories
Development

(DJANGO) How to be redirect to another URL from a view?

I’m new to Django and now I’m getting some problems in redirecting to another URL from the current view. In this case I’d like to be redirect to the Spotify Login page. Here’s my view: ############################################################################# client_id = ‘somestring’; # Your client id client_secret = ‘anotherstring’; # Your secret redirect_uri = ‘http://127.0.0.1:8000/callback/’; # Your redirect […]

Categories
Development

I don’t know how to fix module ‘adoptme.views’ has no attribute ‘addfriends’

from django.conf.urls import url from django.contrib import admin from adoptme import views urlpatterns = [ url(r’^admin/’, admin.site.urls), url(r’^addfriends’, views.addfriends, name=’friends’), url(”, views.home, name=’home’), ] This is the code that has the problem

Categories
Development

How to use template from project in another app?

I’m thinking in organizing all my templates in inside the project: scolarte. But I need to call it from another app. The view is called but getting error: TemplateDoesNotExist at /cuentas/ingreso/ scolarte/templates/scolarte/registration/signup.html I even tried to put the full path to the template in project folder: roles/views.py: class SignUpView(TemplateView): template_name = ‘scolarte/templates/scolarte/registration/signup.html’ # don’t work […]

Categories
Development

Displaying Django model on template

Nothing is being displayed. even without any error log. although the model has data in it models.py class Product(models.Model): name = models.TextField() cat = models.IntegerField() price = models.FloatField() company_id = models.IntegerField() status = models.TextField() views.py def list_products(request): object_list = Product.objects.all() return render(request, ‘index.html’, {‘object_list ‘: object_list}) index.html urls.py urlpatterns = [ path(‘admin/’, admin.site.urls), path(”, views.list_products, […]

Categories
Development

The current path, auth/, didn’t match any of these

I am trying to setup url dispatcher in my project. I have project with follwing structure forecast |___ forecast |_______ __init__.py |_______ settings.py |_______ urls.py |_______ wsgi.py |____authorization |_______ urls.py |_______ models.py |_______ views.py |___ templates |_______ registration |____________ login.html In my forecast/urls.py i put logic of from django.contrib import admin from django.urls import path,include […]

Categories
Development

How to return data from a database for a logged-in user in Django Rest Framework?

Scenario: I have two APIs currently. A RegisterAPI and a LoginAPI. The RegisterAPI registers a new user and a LoginAPI allows them to access their details only. I used JWT authentication as well. I want to retrieve data from the database for a particular user who logs in using the Login API in DRF. My […]