Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
ValueError at /blog/addblog
I am trying to implement the add post section in my website where the user can add his blog. the page looks like this: but when I am trying to post by clicking the post button I get this error: ValueError at /blog/addblog Field 'sno' expected a number but got 'blog title'. Request Method: POST Request URL: http://127.0.0.1:8000/blog/addblog Django Version: 3.1 Exception Type: ValueError Exception Value: Field 'sno' expected a number but got 'blog title'. Exception Location: C:\Users\jayant nigam\projects\practise\lib\site-packages\django\db\models\fields\__init__.py, line 1776, in get_prep_value Python Executable: C:\Users\jayant nigam\projects\practise\Scripts\python.exe Python Version: 3.8.5 Python Path: ['C:\\Users\\jayant nigam\\projects\\everythingcs', 'C:\\Python38\\python38.zip', 'C:\\Python38\\DLLs', 'C:\\Python38\\lib', 'C:\\Python38', 'C:\\Users\\jayant nigam\\projects\\practise', 'C:\\Users\\jayant nigam\\projects\\practise\\lib\\site-packages'] Server time: Sat, 24 Oct 2020 15:17:48 +0530 blog models.py: class Post(models.Model): sno = models.AutoField(primary_key=True) title = models.CharField(max_length=50) content = RichTextField(blank=True, null=True) # content = models.TextField() author = models.CharField(max_length=50) slug = models.SlugField(max_length=200) timeStamp = models.DateTimeField(auto_now_add=True) class Meta: ordering = ['-timeStamp'] def __str__(self): return self.title + " by " + self.author views.py def addblog(request): if request.method == 'POST': title = request.POST.get('title') content = request.POST.get('content') author = request.POST.get('author') slug = request.POST.get('slug') blog = Post(title, content, author, slug) blog.save() return render(request, 'blog/add_post.html') add_post.html {% extends 'base.html' %} {% block title %} add post {% endblock title %} {% block body %} … -
override admin.site make admin.py another app doesn't show at django admin
On my project, there are multiple app, so i also have admin.py each folder. Here are some of my admin.py api/admin.py from django.contrib import admin from .models import Message @admin.register(Message) class MessageAdmin(admin.ModelAdmin): list_display = ['source','name','created'] list_filter = ['source','created'] search_fields = ['message'] dummy/admin.py from django.contrib.admin import AdminSite from dummy.forms import MyAdminLoginForm # export admin.py another app from api.models import Message from api.admin import MessageAdmin class MyAdminSite(AdminSite): login_form = MyAdminLoginForm login_template = 'dummy/templates/admin/login.html' site = MyAdminSite() site.register(Message,MessageAdmin) Since i wanna use captcha on django admin login, i should override the login form that inherit from AdminSite via dummy/admin.py. After that i registering the custom login on the main url from django.contrib import admin from django.urls import path, include from dummy.admin import site admin.site = site urlpatterns = [ path('admin/', admin.site.urls), path('api/', include('api.urls')) ] You can see that i re registering the api/admin.py on the dummy/admin.py, i did it because if i didn't re registering the api/admin.py, it won't be show at the django admin. what should i do to make the admin.py another app doesn't need to be re register like it used to be when i use custom login form that inherit from AdminSite -
Best way to save data serialized by Django Restful frameork to django storage?
I have a requirement to save some data serialized from django restful framework. My view is on a url like /api/fruits/status=ripe I can save the data using the test client, is that the best way, or are there other better ways to do the same thing ? -
Why in django admin foreign key displays attribute value but in angular and database it returns id?
In Django admin, foreign key displays attribute value but in angular it returns id. DepartmentID is a foreign key which is displayed as dpt_name in dajngo admin but in database and anguar it is stored as id. How to Display Foreign Key Value instead of ID in Angular 9? models.py Department table class Department(models.Model): DepartmentID = models.CharField(max_length=20, primary_key = True, verbose_name='Department ID') dpt_code = models.CharField(max_length=20, verbose_name='code', unique = True, blank = False, null = False) dpt_name = models.CharField(max_length=50, verbose_name='name', unique = True, blank = False, null = False) class Meta: db_table = '"tbl_department"' verbose_name_plural = "Department" def __str__(self): return self.dpt_name Program Table class Program(models.Model): programCode = models.CharField(max_length=3, primary_key = True, verbose_name='Program Code', unique = True) pro_name = models.CharField(default = 'B.Sc. Engg. in CSE', max_length=50, verbose_name='name', blank = False, null = False) pro_shortForm = models.CharField(default = 'CSE',max_length=20, verbose_name='short Form', blank = False, null = False) DepartmentID = models.ForeignKey('Department', on_delete=models.CASCADE, verbose_name='department', db_column="DepartmentID") TYPE_CHOICES = ( ('honours', 'honours'), ('masters', 'masters'), ('diploma' , 'diploma'), ('PhD', 'PhD'), ) pro_type = models.CharField(default = 'honours', max_length=7, choices=TYPE_CHOICES, verbose_name='type') class Meta: db_table = 'tbl_program' verbose_name_plural = "Program" def __str__(self): return self.pro_name -
How to fetch the data from an API?
I want to fetch the data from an API. Let's consider the route be "https://api.rikesh.com/posts". Method: GET How to create an API view to fetch the data from the link and display a JSON object as a response in Django Rest Framework? Do I need to use a serializer? Kindly help me to create the views.py function. -
Django - too many values to unpack (expected 2)
I'm trying to create a custom backend where an user uses a private key and a secret key to view an API endpoint that i made uing Django Rest Framework. I already know this isn't the best in terms of security, but since the endpoint is only for viewing data (it only has the GET method) it's not a big deal here. Here is my code: class TokenMiddleware(AuthenticationMiddleware): def process_request(self, request): try: token = request.GET[TOKEN_QUERY_PUBLIC] secret = request.GET[TOKEN_QUERY_SECRET] except KeyError: raise ValidationError(detail="Missing parameter in auth") user = auth.authenticate(request, token=token, secret=secret) if user: # The token is valid. Save the user to the request and session. request.user = user auth.login(request, user) else: raise ValidationError(detail="AUTH FAILED") class TokenBackend(ModelBackend): def authenticate(self, request, token=None, secret=None): if not token: return None try: publicQuery = User.objects.get(api_keys__public=token) if publicQuery != None: privateQuery = Api_keys.objects.get(public=token, secret=secret) if privateQuery.secret == secret: return User.objects.get(username=publicQuery) else: return None else: return None except User.DoesNotExist: # A user with that token does not exist return None def get_user(self, user_id): try: return User.objects.get(pk=user_id) except User.DoesNotExist: return None And here is the Api_keys model: class Api_keys(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) public = models.CharField(max_length=30, blank=True) secret = models.CharField(max_length=30, blank=True) The problem with this code is that … -
Django not commiting to Database if response is rendered differently
I have the following code: # ... # obj creation logic # ... txt = "*BULK LIST*\n\n" for item in obj_list: txt += f"*Label*: {item.label}\n*Item Code*: {item.id}\n*Date Created*: {item.created_date}\n\n" txt += "========================\n\n" # Line with issue return http.HttpResponse( txt, content_type="text/plain" ) The objects in obj_list are only saved to database if the response is returned as shown above. Now, i've been reviewing my code on this project and this part was just too dirty, so I created a template PROJECT_ROOT/templates/bulk_view.html so that presentation will be handled separately in there. Here is the tiny change I made: # same object creation logic as above, removed 'txt' and the forloop concatenating the strings for presantation. # change made on the returned response return http.HttpResponse( render(self.request, "bulk_view.html", {"items": obj_list}) ) The items render correctly, with their ids implying they have been saved to the database. But that's not what's happening. They are not in the database, and also, the id increments on each save(). I'm using Django 3.1 and Postgres 12.4 -
Ecommerce Admin panel and Api in Django
I have an urgent task where I need a Custom made Ecommerce Admin panel and API written in Django language, it is intended to be used for developing an Ecommerce mobile application. I would be glad if you could share link or any useful material concerning it. Thanks in anticipation -
Should I split my Django and DRF project into separate projects?
I am currently at the planning stage of an app that will consist of standard Django part for supervisors that can perform all CRUD operations on employee users mostly add, delete and view statistics - viewed in browser (no frontend framework just using Djangos server side rendering), two step email authentication on each login, session based auth DRF part for employees - API connected to mobile app, authentication based on device ID. (no username, or password) DRF part for clients to contact the supervisors if employees do something wrong - Token or JWT based authentication using passcode delivered by mail. I am not used to splitting Django projects into multiple sub-projects (or using same database for different projects) but it feels like every part of the project should be a standalone app due to different authentication type and the fact of simultaniousily using DRF with standard Django Can anyone who had similar problem or has some experience, advise what should I do considering different authentications and overall different user types in this project? What would be pros and cons of going into solo or multiple projects? Thanks in advance! -
The password field is not reacting based on the class attibute i passed in the widget , In django form.py file,
The username and email field are taking the class which i gave , but the password field is not taking the form-control class i gave i am using the "UserCreationForm" from django.contrib.auth.form and the "User" model from the djano.contrib.auth.model widgets = { 'username': TextInput(attrs={'class':'form-control'}), 'email': TextInput(attrs={'class':'form-control'}), 'password1': PasswordInput(attrs={'class':'form-control'}), 'password2': PasswordInput(attrs={'class':'form-control'}), } [This is the output i am getting but i need the password fields to be responsive with the 'form control' class][1] [1]: https://i.stack.imgur.com/McJ8J.png -
How to fix “ '" is not a valid UUID.”
I want to let user re-order/sort table of content with drag and drop. And whene I push "Submit order" button (after re-order) I have error: ''' ValidationError at /save-group-ordering/ ['“” is not a valid UUID.'] Request Method: POST Request URL: http://127.0.0.1:8000/save-group-ordering/ Django Version: 3.0.2 Exception Type: ValidationError Exception Value: ['“” is not a valid UUID.'] ''' I only start work with django and I not understand what I am doing wrong. Here is my models.py ''' class Task(models.Model): project = models.ForeignKey(Project, null=True, on_delete=models.CASCADE) title = models.CharField(max_length=300, null=True) complete = models.BooleanField(default=False) deadline = models.DateField('Deadline of the task (year, month, day)', default=date.today) created = models.DateTimeField(auto_now_add=True,null=True) lookup_id = models.UUIDField(default=uuid.uuid4, editable=False, db_index=True) order = models.IntegerField(blank=False, default=100_000) def __str__(self): return self.title def deadline_func(self): days = self.deadline - date.today() return days ''' Here is my urls.py ''' from django.urls import path from . import views urlpatterns = [ path('' , views.projects_list, name="list"), path('create_project/' , views.createProject, name="create_project"), path('deadline_project/<str:pk>' , views.deadlineProject, name="deadline_project"), path('update_project/<str:pk>' , views.updateProject, name="update_project"), path('delete_project/<str:pk>' , views.deleteProject, name="delete_project"), path('create_task/<str:pk>' , views.createTask, name="create_task"), path('save-group-ordering/', views.save_new_ordering, name='save-group-oldering'), path('deadline_task/<str:pk>' , views.deadlineTask, name="deadline_task"), path('update_task/<str:pk>' , views.updateTask, name="update_task"), path('delete_task/<str:pk>' , views.deleteTask, name="delete_task"), ] ''' Here is my views.py ''' @require_POST def save_new_ordering(request): form = OrderingForm(request.POST) if form.is_valid(): ordered_ids = form.cleaned_data["ordering"].split(',') with … -
Setting up apache2 on lightsail (AWS)
whenever i run the following lines on a Linux terminal, after configuring my config files for wsgi sudo service apache2 restart I get the following error: ob for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details. On running journalctl -xe, I get: Oct 24 06:08:07 ip-172-26-12-135 dhclient[428]: XMT: Solicit on eth0, interval 119120ms. Oct 24 06:08:25 ip-172-26-12-135 sudo[24683]: bitnami : TTY=pts/0 ; PWD=/opt/bitnami/projects/PROJECT/PROJECT ; USER=root ; COMMAND=/usr/sbin/service apache2 restart Oct 24 06:08:25 ip-172-26-12-135 sudo[24683]: pam_unix(sudo:session): session opened for user root by bitnami(uid=0) Oct 24 06:08:25 ip-172-26-12-135 systemd[1]: Starting The Apache HTTP Server... -- Subject: A start job for unit apache2.service has begun execution -- Defined-By: systemd -- Support: https://www.debian.org/support -- -- A start job for unit apache2.service has begun execution. -- -- The job identifier is 9535. Oct 24 06:08:26 ip-172-26-12-135 apachectl[24689]: apache2: Syntax error on line 225 of /etc/apache2/apache2.conf: Syntax error on line 45 of /etc/apache2/sites-enabled/dj Oct 24 06:08:26 ip-172-26-12-135 apachectl[24689]: Action 'start' failed. Oct 24 06:08:26 ip-172-26-12-135 apachectl[24689]: The Apache error log may have more information. Oct 24 06:08:26 ip-172-26-12-135 systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE -- Subject: Unit process exited -- Defined-By: systemd -- Support: … -
Django: Count and Sum items in the same item_category within a queryset
It seems this should be fairly simple, but i'm stuck. I'm trying to Count and Sum items in the same item_category within a queryset. views.py #counting data = AllData.objects.values('item','item_category').annotate(item_count=Count('item'),item_category_count=Count('item_category')) print("Data",data) produces: Data <QuerySet [{'item': 'Item1', 'item_category': 'Sport', 'item_count': 15, 'item_category_count': 15)},{'item': 'Item2', 'item_category': 'Leisure', 'item_count': 12, 'item_category_count': 12)},{'item': 'Item3', 'item_category': 'Sport', 'item_count': 10, 'item_category_count': 10)},]> The item_counts are ok, but the output i'm looking for needs to Sum the the number of items in the similar category. Something like this: data = AllData.objects.values('item','item_category').annotate(item_count=Count('item'),item_category_count=Sum(Count('item_category'))) But this produces an error: Cannot compute Sum('Count'): 'Count' is an aggregate The results i'm looking for should look like this: Data <QuerySet [{'item': 'Item1', 'item_category': 'Sport', 'item_count': 15, 'item_category_count': 25)},{'item': 'Item2', 'item_category': 'Leisure', 'item_count': 12, 'item_category_count': 12)},{'item': 'Item3', 'item_category': 'Sport', 'item_count': 10, 'item_category_count': 25)},]> Here, the number of items in the 'Sport' category has been summed as 10+15 to produce 'item_category_count': 25 Thanks -
Elastic Beanstalk-Django: 500 deploy Internal Server Error
My questions might similar to other stackoverflow's questions. I have tired every single questions' solutions but none of them did not work. I have created simple Django app and it works locally fine. My app structure like this: . This my .ebextensions django.config. option_settings: aws:elasticbeanstalk:container:python: WSGIPath: DjangoElasticbeanstalkdeploy/wsgi.py I have used default_platform: Python 3.6 running on 64bit Amazon Linux. My environment Heath looks good. Everything looks ok to me but when I click the url I am getting this error. -
How to allow a form to submit, but prevent blank fields from being saved using Django Admin?
I am using Django Admin, and have a model like this: class Item(models.Model): id = models.CharField(max_length=14, primary_key=True) otherId = models.CharField(max_length=2084, blank=True) I want id to be required and unique, and I want otherId to be optional on the Admin form, but if otherId is provided, it has to be unique. The problem I am running into is, whenever I create an instance of Item using the Admin form and I do not provide an otherId, Django tries to save the otherId field as a blank value, but this means the second time I try to save an instance with a blank otherId value it violates the column's unique constraint and fails. I need Django to check if the otherId field is falsey before saving, and if it is falsey, do not save that empty value along with the model. Is this possible? -
Django update model fields after a certain time
I have a Assignment model, which has the following attributes for now: title (char Field), deadline(date and time field), closed (boolean field). The closed field denotes if the assignment is past deadline or not. The closed field is false by default. So now, what I want is that, when an object of the model is created the closed field should be updated automatically on the basis of the deadline. Say the deadline is after 2 hours. Then the closed field should become true after 2 hours. What is the best way to do this? Does Django provide any field of this type; which would update itself after a certain time? -
How to make conditional sum for related items when use values() in Django?
I have two models class OrderItem(models.Model): name = models.CharField(max_length=64) price = models.FloatField() quantity = models.FloatField(default=0.0) class OrderModifier(models.Model): item = models.ForeignKey( 'order.OrderItem', related_name="modifiers", on_delete=models.CASCADE) name = models.CharField(max_length=64) price = models.FloatField() void_status = models.BooleanField(default=False) I need to make a sum of price per unique name of OrderItem it works like items = OrderItem.objects.all() qs = items.annotate().values('product__name'). \ annotate( amount=Sum('quantity'), total=Sum(F('quantity') * (F('price'))) ) But I need to add sum of all related Modifiers only when their void_status = False Tried like qs = items.annotate().values('product__name'). \ annotate( amount=Sum('quantity'), total=Sum(F('quantity') * (F('price'))) + Sum( F('quantity') * Case(When(modifiers__void_status=False, then='modifiers__price'), default=0)) ) But that changes my amount (adds to Item qty N of related modifiers) -
Django Trying to send (smtp) email but connection refused
I am using Mac Catalina 10.15.7 / django 3.1.2 / python 3.8.5. I am trying to send an email from django. First, I have defined these in settings.py EMAIL_BACKEND='django.core.mail.backends.smtp.EmailBackend' EMAIL_USE_TLS=True EMAIL_HOST='smtp.gmail.com' EMAIL_PORT=587 EMAIL_HOST_USER='MYID@gmail.com' EMAIL_HOST_PASSWORD='MYPASSWORD' SERVER_EMAIL='MYID@gmail.com' DEFAULT_FROM_EMAIL=EMAIL_HOST_USER and then, I went to the gmail setting and 1) enabled IMAP usage and 2) (in the account's security settings) enabled the usage of the low-security application (https://www.google.com/settings/security/lesssecureapps) So then, in my pycharms' python console, from django.core.mail import EmailMessage email = EmailMessage('subject text', 'body text', to=['RECEIVINGEMAILID@gmail.com']) but I get these errors: Traceback (most recent call last): File "<input>", line 1, in <module> File "/Users/capstone1/lib/python3.8/site-packages/django/core/mail/message.py", line 225, in __init__ self.from_email = from_email or settings.DEFAULT_FROM_EMAIL File "/Users/capstone1/lib/python3.8/site-packages/django/conf/__init__.py", line 83, in __getattr__ self._setup(name) File "/Users/capstone1/lib/python3.8/site-packages/django/conf/__init__.py", line 64, in _setup raise ImproperlyConfigured( django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_FROM_EMAIL, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. so I can't do the next step email.send() According to the error description, I thought maybe I used write the DJANGO_SETTINGS_MODULE block in settings.py like - DJANGO_SETTINGS_MODULE = [ { 'EMAIL_BACKEND':'django.core.mail.backends.smtp.EmailBackend', 'EMAIL_USE_TLS':True, 'EMAIL_PORT':587, 'EMAIL_HOST':"smtp.gmail.com", 'EMAIL_HOST_USER':'MYID@gmail.com', 'EMAIL_HOST_PASSWORD':'MYPASSWORD', 'SERVER_EMAIL':'MYID@gmail.com', 'DEFAULT_FROM_EMAIL':"MYID@gmail.com" } ] but it's still giving me the same error. -- OR, if I do … -
How to generate a random product_id int to MySQL when adding a new product via Django Admin
I'm trying to add a "product_id" alongside new products to a MySQL database for use in an ecommerce website running Django. I then want to use these product_id values to be searchable from within the eCommerce site. For this reason they only need to be 5 characters long. The product class in models.py looks like this: from django.utils.crypto import get_random_string class Product(models.Model): title = models.CharField(max_length=255) slug = models.SlugField(max_length=255) category = models.ForeignKey(Category, related_name='products', on_delete=models.CASCADE) product_id = models.IntegerField(get_random_string(5, 1234567890)) # Max length 5, numerals only description = models.TextField(blank=True, null=True) price = models.FloatField() When trying to migrate the models to the MySQL server I get: File "C:\Users\user\Desktop\ecommerce\apps\store\models.py", line 18, in <module> class Product(models.Model): File "C:\Users\user\Desktop\ecommerce\apps\store\models.py", line 22, in Product product_id = models.IntegerField(get_random_string(5, 1234567890)) # Create a random numeric id for each product File "C:\Users\user\Desktop\ecommerce\venv\lib\site-packages\django\utils\crypto.py", line 74, in get_random_string return ''.join(secrets.choice(allowed_chars) for i in range(length)) File "C:\Users\user\Desktop\ecommerce\venv\lib\site-packages\django\utils\crypto.py", line 74, in <genexpr> return ''.join(secrets.choice(allowed_chars) for i in range(length)) File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\random.py", line 288, in choice i = self._randbelow(len(seq)) TypeError: object of type 'int' has no len() As I understand I should be able to set the length of an integer and set it as a numeric id to be stored each time a new product is … -
Save json data into my db using django and postgresql
I'm working with django and postgres, I've a large json data that i want to save into my db but idk how. My json data looks like this: { "Name": "some name", "Direction": "Street name", "City": "City", "Region": "Region", "DirectionGeo": "Street with geopy", "Category": "Category", "ExternalCode": "Code", "lat": latitude, "lon": longitude } That's all the data I want to save, can someone give me an advice on how I can save my data into the db using python please -
column "xx_xx" can only be updated to DEFAULT - DJANGO
Im trying to update some values (via django) at a table on Postgres that contains a Generated column. This is the error im getting: column "xx_xx" can only be updated to DEFAULT See complete error here -
How can i test this url in django
Hi friend i'm trying to test this urls but i don't how do that i have the following code # Method of the test def testViewDeleteUserIsResolved(self): url = reverse('inventory:viewDeleteUser', args={'idUser': tbUser.objects.first().id}) self.assertEquals(resolve(url).func,viewDeleteUser) # Url to try path('viewDeleteUser/?P<idUser>[0-9a-f-]+', views.viewDeleteUser, name='viewDeleteUser'), -
Update data into django database asynchronously
hope you all are doing well. I am trying to make a chat application that with read receipts, I have created the basic chat functionality but when implementing the status of a message, it doesn't update the database, the thing that I am trying to do is we trigger an event when a user visits the window and sends a json response via django channels with status in it we can fetch the data asynchronously but I am not able to update the status field in it. This is how my consumers.py looks like consumers.py async def websocket_receive(self,event): print("received",event) front_text = event.get('text', None) if front_text is not None: loaded_dict_data = json.loads(front_text) status = loaded_dict_data.get("status") message = eval(loaded_dict_data.get("msg"))["id"] self.get_message(message) @database_sync_to_async def get_message(self,message): to_mark=ChatMessage.objects.get(pk=message).update(status="Read") It doesn't throw out any error, but it doesn't update data in database Any help would be much appreciated. -
I can't add Many-To-Many relation in Django
I have 2 models: class Item(models.Model): name = models.CharField(max_length=100) price = models.FloatField(max_length=20) shelfLife = models.BooleanField() def __str__(self): return self.name @property def shL(self): temp = "Doesnt' have shelf life" if(self.shelfLife): temp = "Does have sehlf life" return temp class Order(models.Model): num = models.CharField(max_length=20) date = models.DateField() items = models.ManyToManyField(Item) def __str__(self): return self.num according to this doc I can do: elif request.method == "POST": list_items = request.POST.getlist('arr[]') # get list of items order_num = request.POST.getlist('o_n') # get order num order_date = request.POST.getlist('o_d') # get order date order = Order(num=order_num[0], date=order_date[0]) order.save() for i in range(len(list_items)): item_name = str(list_items[i]) item = Item.objects.filter(name=item_name) order.items.add(item) To fetch each item that I need, I loop through the list_items list of strings and filter each object request by this string and then just add the item to the many-to-many field of the order model. In addition, when I fetch item = Item.objects.filter(name="Salad") the returned QuerySet is not empty, however, if I pass a string variable to the name filter it returns an empty QuerySet. There is a trace of another id error bellow I would appreciate any help! Thanks Error: Internal Server Error: /api/order/item-list/ Traceback (most recent call last): File "/home/anton/miniconda3/envs/cw/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 1774, in get_prep_value return … -
Django folder without registering it as an app
RoR dev learning Django here. I've inherited a Django project, and I've learned that we can have apps, to encapsulate functionality. To do so I have to create an app like this: django-admin startapp my_app and then add the app to settings.py: INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'my_project.my_app', ) This works fine. However I have found some folders in this Django project for example named: /my_feature that has its own urls.py file and models and views files, just like an app. The my_feature functionalities work just fine. Requests are routed, views called, etc... However, they are NOT present in settings.py as an app. my_feature is nowhere to be found in INSTALLED_APPS or anywhere else (searched the entire project and nothing). So how is this working without it being registered as an app? If a folder with models and views and routes can just be placed in Django project root and will "just work", why are we taught it must be added to INSTALLED_APPS ?