Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How can I use exclude or filter with CharField?
I have a Good model with this Field: Size = models.ManyToManyField('Size') And Size model: class Size(models.Model): size = models.CharField(max_length = 15) def __str__(self): return self.size In views.py I need to exclude 1 size, so I try: good1 = Good.objects.get(id = good_id) good1.Size.exclude(size = 'XS') But exclude doesn't work... I think it's because of impossibility to compare size field with string 'XS' How can I fix it? -
How to set correct path in anchor tag
I'm working on a simple Django app. Right now I can link different pages via anchor tags using href="{ url 'name'} which I believe is the "Django way to do things". The problem is that as soon as I try to link a file that exists in a different location, I get an error. I've tried changing the name, function, and path, but I'm stuck. The errors vary, but it's usually related to trying to find pyoop.html in the wrong location. The only difference really is the pyoop.html is inside an "extra folder" which is not the case for the other files. # views.py def pyoop(request): return render(request, 'book/pages/pyoop.html') #urls.py urlpatterns = [ ... path('py-oop/', views.pyoop, name="book-pyoop") ] #index.html <a href="{ url 'book-python-oop'}">Link to Python-oop</a> pyoop.html is the only file inside the 'pages' folder, everything else is inside the 'book' folder. -
django static file : The requested resource was not found on this server
my html <!DOCTYPE html> {% load static %} <html> <head> <title>Fish store</title> <link rel="stylesheet" type="text/css" href="{% static 'css/animate.css' %}"> </head> <body> <h2>Home page</h2> </body> </html> my settings.py INSTALLED_APPS = [ 'fish.apps.FishConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ] in fish app I have static folder and css folder, and then animate.css fish/static/css/animate.css main url urlpatterns = [ path('admin/', admin.site.urls), path('',views.index) ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) Now I try to access http://localhost:8000/static/css/animate.css it shows: Not Found The requested resource was not found on this server. -
Django not uploading staticfiles to Amazon S3
I am trying to upload my static files onto Amazon S3 but it is still collecting the static files on a local folder. Any idea of how I can get my Django collectstatic to upload onto S3? Here are the relevant code bits: Using Boto and django-storages. The undesired behavior (0 static files copied since I just ran it): > python manage.py collectstatic > 0 static files copied to '/Users/michaelninh/PycharmProjects/Collab/staticfiles', 132 unmodified, 292 post-processed. Installed Apps: 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'whitenoise.runserver_nostatic', 'django.contrib.staticfiles', 'django.contrib.sites', # third party 'allauth', 'allauth.socialaccount', 'allauth.account', 'multiselectfield', 'easy_thumbnails', 'image_cropping', 'storages', # first party 'user.apps.UserConfig', 'profiles.apps.ProfilesConfig' ] Connection to S3 AWS_ACCESS_KEY_ID = 'XXX' AWS_SECRET_ACCESS_KEY = 'YYY' AWS_STORAGE_BUCKET_NAME = 'ZZZ' AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME AWS_S3_OBJECT_PARAMETERS = { 'CacheControl': 'max-age=86400', } AWS_LOCATION = 'static' STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'), ] STATIC_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, AWS_LOCATION) STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')``` -
Optimizing Django REST Framework queries using prefetch_related
I'm not quite understanding the concept of prefetch_related for optimizing the related_name queries. However I seem to be in much need of it at this moment. I wish to optimize the following queryset as I have a bunch of similar looking queries: return Customer.objects.filter( Q(company__administrators__user=user) | Q(company__employees__employee_roles__user=user, company__employees__employee_roles__group__permissions=40) | Q(projects__project_roles__user=user, projects__project_roles__group__permissions=40, access='Restricted') | Q(projects__schedules__schedule_roles__user=user, projects__schedules__schedule_roles__group__permissions=40, projects__access='Restricted', access='Restricted') | Q(customer_roles__user=user, customer_roles__group__permissions=40) ).distinct() What would be the optimal way to do this using prefetching? Currently this query takes about 10 seconds on the development server, compared to < 1 second when returning Customer.objects.all(). Thus I have figured it boils down to the query and not serialization of the data. -
Creating input view for many to 1 relationship in Django
I'm attempting to create a page where users can input a recipe. Users would need to name the recipe, then input a list of ingredients and steps to follow during the recipe. I've set up 4 models Recipe - stores the name as well as the user inputing the recipe Ingredients - stores all ingredients possible (with potential to add new ingredients) Recipe_Ingredients - pairs unlimited number of ingredients to a recipe Step - allows user to enter an unlimited number of steps for a recipe I'm able to input recipes through the admin page, however this is: A. clunky B. doesn't allow non-admins to enter new recipes from django.db import models from django.contrib.auth.models import User # Create your models here. class Ingredient(models.Model): name = models.CharField(max_length=500, blank=False, null=False) link = models.CharField(max_length=500, blank=True, null=True) def __str__(self): return self.name class Recipe(models.Model): title = models.CharField(max_length=250, blank=False, null=False) notes = models.TextField(blank=True, null=True) author = models.ForeignKey(User, on_delete=models.CASCADE) def __str__(self): return self.title class Recipe_Ingredient(models.Model): recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE) ingredient = models.ForeignKey(Ingredient, on_delete=models.CASCADE) unit = models.ForeignKey(Unit, on_delete=models.CASCADE, blank=True, null=True) amount = models.DecimalField(decimal_places=3, max_digits=10000) class Step(models.Model): recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE) step_number = models.IntegerField(default=1) step = models.TextField(blank=True, null=True) def __str__(self): return self.step I'm hoping to create a page where … -
Cannot overwrite attachment values DATABASE_URL
How do i change the database_url in heroku for my django app? heroku addons:detach DATABASE -a is not working -
I have trouble finding the site
I do a search for articles on the site. Filtering should be by article title. Data from the search should be displayed in the template/ I tried to filter the data using order_by and filter views.py def post_search(request): form = SearchForm() if 'query' in request.GET: form = SearchForm(request.GET) search = request.GET['username'] if form.is_valid(): cd = form.cleaned_data results = SearchQuerySet().models(Articles).filter(content=cd['query']).load_all() total_results = results.count() return render(request, 'news/posts.html', {'form': form, 'search': search, 'cd': cd, 'results': results, 'total_results': total_results}) posts.html {% if "query" in request.GET %} <h1>Posts containing "{{ cd.query }}"</h1> <h3>Found {{ total_results }} result{{ total_results|pluralize }}</h3> {% for result in results %} {% with post=result.object %} <h4><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h4> {{ post.body|truncatewords:5 }} {% endwith %} {% empty %} <p>There are no results for your query.</p> {% endfor %} <p><a href="{% url 'post_search' %}">Search again</a></p> {% else %} <h1>Search for posts</h1> <form action="{% url 'post_search' %}" method="get"> <h3>Search</h3><input style=" border: 3px solid #4242A3; border-radius: 15px ; " type="text" name="search" value=" searchк "> <br> <input type="submit" value="Search"> </form> {% endif %} urls.py path('search/', views.post_search, name='post_search'), models.py class Articles(models.Model): title = models.CharField(max_length= 200) post = models.TextField() date = models.DateTimeField() img = models.ImageField(upload_to='', default="default_value") tags = TaggableManager() article_like = models.IntegerField(default='0') article_dislike = models.IntegerField(default='0') … -
Make required False in django graphene with relay
Django-Graphene with relay makes id required to get an object, I want to make required=False on my Node, so I can get the node by the logged in user instead of the user ID class Customer(models.Model): user = models.OneToOneField(User) class CustomerNode(DjangoObjectType): class Meta: model = Customer interfaces = (graphene.relay.Node,) @classmethod @login_required def get_queryset(cls, queryset, info): # This will work return queryset.get(user=info.context.user) class Query(graphene.ObjectType): customer = graphene.relay.Node.Field(CustomerNode) all_customers = DjangoFilterConnectionField(CustomerNode) query getCustomer { customer(id: "XXX") { # I don't want to pass this parameter! id } } -
Getting same thread id inside celery workers
I tried getting the current thread id and process id while running a task inside a celery worker process. I have set prefetch multiplier to 1 and I have 4 cpu core machine, so there will be 4 worker processes running for each workers. I have only 1 worker running ( 4 worker processes). As per my understanding each of the worker processes actually handles the execution of task. When I run 4 tasks simultaneously I tried getting the process id and thread id inside the task using os.getpid() and threading.get_ident() respectively. To no surprise, for every task running I got the same set of 4 process_id (as there are 4 worker processes running), but the thread id for each of the process are same. I am not able to understand how is this possible. Following is my observations when running tasks: > log: pid id: 513, t_id 140373758563328 > log: pid id: 514, t_id 140373758563328 > log: pid id: 513, t_id 140373758563328 > log: pid id: 513, t_id 140373758563328 > log: pid id: 513, t_id 140373758563328 > log: pid id: 513, t_id 140373758563328 > log: pid id: 578, t_id 140280371217408 > log: pid id: 579, t_id 140280371217408 -
django.core.exceptions.FieldError: Local field 'email' in class 'User' clashes with field of similar name from base class 'AbstractUser'
I created a AbstractUser class in my reg_group app's models.py from django.contrib.auth.models import AbstractUser from django.db import models from django.utils.html import escape, mark_safe class User(AbstractUser): is_client = models.BooleanField(default=False) is_agency = models.BooleanField(default=False) is_vendor = models.BooleanField(default=False) email = models.EmailField(max_length=255, default=None, blank=True, null=True) class User_Info(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True) def __str__(self): return self.user.name I also have another app notification whose models.py is such: from django.db import models from swampdragon.models import SelfPublishModel from .serializers import NotificationSerializer class Notification(SelfPublishModel, models.Model): serializer_class = NotificationSerializer message = models.TextField() When i run python manage.py runserver i get the error django.core.exceptions.FieldError: Local field 'email' in class 'User' clashes with field of similar name from base class 'AbstractUser' But there is no email field in notification database. The raw code of database is such : CREATE TABLE "notifications_notification" ( "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "level" varchar(20) NOT NULL, "actor_object_id" varchar(255) NOT NULL, "verb" varchar(255) NOT NULL, "description" text, "target_object_id" varchar(255), "action_object_object_id" varchar(255), "timestamp" datetime NOT NULL, "public" bool NOT NULL, "action_object_content_type_id" integer, "actor_content_type_id" integer NOT NULL, "recipient_id" integer NOT NULL, "target_content_type_id" integer, "deleted" bool NOT NULL, "emailed" bool NOT NULL, "data" text, "unread" bool NOT NULL, FOREIGN KEY("recipient_id") REFERENCES "reg_group_user"("id") DEFERRABLE INITIALLY DEFERRED, FOREIGN KEY("target_content_type_id") REFERENCES "django_content_type"("id") … -
ImproperlyConfigured exception when starting server. "The included URLconf 'percentsystem .urls' does not appear to have any patterns in it"
I making a Django website, and everything was alright until the moment when i added new path in urls.py: app's urls.py from django.urls import path from . import views urlpatterns = [ path('', views.members_list, name='members_list_url'), path('create/', views.MemberCreate.as_view(), name='member_create_url'), path('<str:nickname>/', views.MemberPage.as_view(), name='member_page_url') ] and an error message occured: (venv) D:\Documents\Desktop\percents_system\app\percentsystem>manage.py runserve r Watching for file changes with StatReloader Performing system checks... Exception in thread django-main-thread: Traceback (most recent call last): File "D:\Documents\Desktop\percents_system\venv\lib\site-packages\django\urls\ resolvers.py", line 581, in url_patterns iter(patterns) TypeError: 'module' object is not iterable During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:\program files\python36\Lib\threading.py", line 916, in _bootstrap_inn er self.run() File "c:\program files\python36\Lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "D:\Documents\Desktop\percents_system\venv\lib\site-packages\django\utils \autoreload.py", line 54, in wrapper fn(*args, **kwargs) File "D:\Documents\Desktop\percents_system\venv\lib\site-packages\django\core\ management\commands\runserver.py", line 117, in inner_run self.check(display_num_errors=True) File "D:\Documents\Desktop\percents_system\venv\lib\site-packages\django\core\ management\base.py", line 390, in check include_deployment_checks=include_deployment_checks, File "D:\Documents\Desktop\percents_system\venv\lib\site-packages\django\core\ management\base.py", line 377, in _run_checks return checks.run_checks(**kwargs) File "D:\Documents\Desktop\percents_system\venv\lib\site-packages\django\core\ checks\registry.py", line 72, in run_checks new_errors = check(app_configs=app_configs) File "D:\Documents\Desktop\percents_system\venv\lib\site-packages\django\core\ checks\urls.py", line 13, in check_url_config return check_resolver(resolver) File "D:\Documents\Desktop\percents_system\venv\lib\site-packages\django\core\ checks\urls.py", line 23, in check_resolver return check_method() File "D:\Documents\Desktop\percents_system\venv\lib\site-packages\django\urls\ resolvers.py", line 398, in check for pattern in self.url_patterns: File "D:\Documents\Desktop\percents_system\venv\lib\site-packages\django\utils \functional.py", line 80, in __get__ res = instance.__dict__[self.name] = self.func(instance) … -
Django on Nginx subdirectory redirects to root
I have Django 2.2 and am trying to serve it to http://myserver.com/application using Nginx proxy pass. If I try and go to myserver.com/application/admin I get redirect to myserver.com/admin immediately. Is this a setting I should be specifying in Nginx or in Django to avoid this? Django is running in gunicorn, see Nginx.conf: location /static { alias /home/simernes/workspace/django_server/env/static; } location /application { proxy_pass http://localhost:8000/; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto http; proxy_buffer_size 128k; proxy_buffers 8 128k; proxy_busy_buffers_size 256k; } Finally, this is what my urls.py looks like in a project folder "backend": from django.contrib import admin from django.urls import path from django.conf.urls import url, include FORCE_SCRIPT_NAME="/application" STATIC_ROOT="/home/simernes/workspace/django_server/env/static/" app_name='backend' urlpatterns = [ path('admin/', admin.site.urls), url(r'^', include('api.urls', namespace='api')), ] Furthermore, when I go to the root of myserver.com/application I get an error of 404 not found and: Using the URLconf defined in backend.urls, Django tried these URL patterns, in this order: admin/ ^ auth$ [name='auth'] The current path, /, didn't match any of these. Which is not what I expected, as I am configuring to show the urls available in my api app (see urls.py below), but it's not my main concern with this question so … -
How to pass contenteditable text to value attribute in django html file
I have tried finding resource but couldn't get any. I have a html file in templates folder in my django app as {% for comment in comments %} <li contenteditable = "TRUE" >{{comment.text}} <form contenteditable = "FALSE" action = "{% url 'clickedaccept' %}" method = "POST"> {% csrf_token %} <input type = "hidden" name = "acceptedvalue" value = "{{comment.id}}"> <input type = "hidden" name = "selected_option" value = "{{selected_option}}"> <input type = "hidden" name = "selected_autocomplete" value = "{{selected_autocomplete}}"> <input type = "submit" value = "Accept" id = "{{comment.id}}" > </form> {% endfor %} </li> Here the comment.text is extracted from model and is editable. User can edit the text value. There is a form with post method. I want to send the value of content editable text in value attribute of hidden input. How can I achieve it? -
How to structure a daily habit tracking app
Background I'm a personal trainer and trying to build an app that tracks whether or not my clients are working on their daily habits (and bugs them about it at a chosen time every day). I'd love to hear if any of you all have ideas on how to structure this as I'm new to both Django and coding in general. Models I currently have two models: Habits and Checks. Habits represent "What are you working on improving?" and have a ForeignKey to a user. Checks represent "Did you complete your habit today?" and have a ForeignKey to a habit. Current status There is a nice solution where you create all the Checks for a Habit based on it's end date, but I'm trying to structure this with an indefinite end date because, as a coach, then I can show hard data when someone isn't making progress. Though I am still willing to accept that maybe this app would work better if habits had deadlines. I wrote a custom manage.py script that Heroku runs automatically at the same time every day, but that doesn't scale with users' individual time zones. I run it manually on my local computer. I originally … -
how to compare time spans in python?
Say I have 2 sets of time spans. So one is from 10:00 am to 12:00 pm, the other from 11:00 am to 13:00 pm, both on the same day. How can I easily calculate to find out if they overlap? My code is irrelevant, but just for understanding the use case - I'm developing a Django app where I want to allow building some sort of schedule, something like this: class TimeSpan(models.Model): start = models.DateTimeField() end = models.DateTimeField() class Worker(models.Model): name = models.CharField(max_length=100) limitations = models.ManyToManyField(TimeSpan) Class Shift(models.Model): workers = models.ManyToManyField(Workers) timespan = models.ForeignKey(TimeSpan) I need to be able to compare a TimeSpan object of shifts, with the limitations of each worker. What would be a good way to do that? -
How to hide EMAIL_HOST_PASSWORD in setting.py file?
So, I have an application written with Django and it has a contact page, from where users can send mail using gmail's smtp. For this functionality in settings.py file I wrote EMAIL_HOST_PASSWORD = {'my-own-password'}, and I'm gonna deploy my site on github.io. So, I must hide or encrypt password. What can I do with that ? -
Django - prepopulated_fields slug textfield
Following is my models and admin class. However, slug is not pre-populated? Why? my title is a Textfield. class Deals(models.Model): title = models.TextField() slug = models.SlugField(max_length=1000, db_index=True, unique=True) class DealsAdmin(admin.ModelAdmin): prepopulated_fields = {"slug": ("title",)} list_per_page = 20 admin.site.register(Deals, DealsAdmin) As per Django Docs, prepopulated_fields doesn’t accept DateTimeField, ForeignKey, OneToOneField, and ManyToManyField fields. So, it should accept TextField. Why the slug is not prepoulated? -
Send excel file as a parameter from angular to an endpoint in django
Good I have a query, the question is that I need to upload an excel file with records (to overwrite said records in a BD / or create new records) from angular to django, that is to say I upload the file and I need to process it in a view of django or django rest framework, my question is if it is possible to pass that parameter to an endpoint and how would it be? I'm new to both technologies and I need this for my project -
i can't install hazm on cpanel host
i want to install hazm on cpanel .I use this command to install this package : 'pip install hazm' but it's work in my pc and dont work in my host and get this error : ERROR: Complete output from command /home/newsir/virtualenv/mySite/3.7/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-2kptnz5u/libwapiti/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-8l3jvmao --python-tag cp37: -
Automatically adding a slash at the end of a url
I've got all urls configured correctly, with a trailing slash. Now, whenever I visit a correct url that has no trailing slash, I get the "homepage" (since this is the page to show when a url is wrong). This is a pain in the ass since the url is 'somewhat' correct. I've tried to explicitly enable this with APPEND_SLASH = True in the settings.py but without any success. I'm still in the development phase so no weird rewrite rules from a server. What could be the cause of this? Thanks in advance! -
issue with selenium - find_elements_by_xpath or find_elements_by_tag
I'm having an issue where I'm not sure where lies the issue. I've created a functional test for, called func_tests1.py from selenium import webdriver from selenium.webdriver.common.keys import Keys import time import unittest class NewVisitorTest(unittest.TestCase): def setUp(self): self.browser = webdriver.Firefox() def tearDown(self): self.browser.quit() def test_can_start_a_list_and_retrieve_it(self): self.browser.get('http://localhost:8000') self.assertIn('To-do',self.browser.title) header_text = self.browser.find_elements_by_tag('h1') #this is where lies the issue inputbox = self.browser.find_element_by_id('id_new_item') self.assertEqual( inputbox.get_attribute('placeholder'), 'Enter a to-do item' ) inputbox.send_keys('Buy peacock feathers') #Functional test now checks we can input a to-do item inputbox.send_keys(Keys.ENTER) time.sleep(1) table = self.browser.find_element_by_id('id_list_table') rows = table.find_element_by_tag_name('tr') self.assertTrue( any(row.text == '1: Buy peacock feathers' for row in rows), "New to-do item did not appear in table" ) # There is still a text box inviting her to add another item. # She enters "Use peacock to make a fly" # Edith is very methodical self.fail('Finish the test!') if __name__ == '__main__': unittest.main(warnings='ignore') This is my template, hme.html <html> <head> <title>To-do lists</title> </head> <body> <h1>Your To-do list <h1> <input id="id_new_item" placeholder="Enter a tod-o item"/> <table id="il_list_table"> </table> </body> <!-- --> </html> And last, but not least, this is my test case, tests.py from django.urls import resolve from django.test import TestCase from django.http import HttpRequest from django.template.loader import render_to_string from lists.views import home_page … -
How to stop the active failed error in gunicorn?
I am trying to get the gunicorn to be active and for some reason it failed. When I use --bind 0.0.0.0:8000 myproject.wsgi. It work! I can get on the website fine, but I am getting this error when I input sudo systemctl status gunicorn I get an error and cannot move on to nginx. To give you understanding where everything in my file, I entered a dir command to show. nyfl_djangoline@DjangoNFL:~/sportsproject/portfolio-project/my_app1/first_app$ dir db.sqlite3 first_app1.sock pg_hba.conf requirements.txt sports_app first_app manage.py postgresql.conf sites-enabled todo_list Also sudo nano /etc/systemd/system/gunicorn.service provided me this output: [Unit] Description=gunicorn daemon After=network.target [Service] User=nyfl_djangoline Group=www-data WorkingDirectory=/home/nyfl_djangoline/sportsproject/portfolio- project/my_app1/first_app/first_app ExecStart=/home/nyfl_djangoline/sportsproject/sports_app/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/nyfl_djangoline/sportsproject/portfolioproject/my_app1/first_app/first_app1.sock first_app.wsgi:appliioncation [Install] WantedBy=multi-user.target *Sports_app is the environment for this project I receive a sock file and even sites-enabled for ngnix(whole seperate issue), but when I try to move ngnix I am getting issues and I believe it goes back to gunicorn. I have tried changing the file direction on sudo nano /etc/systemd/system/gunicorn.service, but I keep getting the same issue. I also use sudo journalctl -u gunicorn and I do not get an entries. [Unit] Description=gunicorn daemon After=network.target [Service] User=nyfl_djangoline Group=www-data WorkingDirectory=/home/nyfl_djangoline/sportsproject/portfolio- project/my_app1/first_app/first_app ExecStart=/home/nyfl_djangoline/sportsproject/sports_app/bin/gunicorn -- access-logfile - --workers 3 --bind unix:/home/nyfl_djangoline/sportsproject/portfolio- project/my_app1/first_app/first_app1.sock first_app.wsgi:appliioncat [Install] WantedBy=multi-user.target … -
django+heroku error in createsuperuser "psycopg2.errors.UndefinedTable: relation ”users_profile“ does not exist"
i am new to django,there is no problem in local system for this ,makemigrations,migrate and createsuperuser everything works fine in local system.but when i am trying to deploy in heroku with postgresql makemigrations and migrate ran fine, problem is when i am trying to createsuperuser, it is giving me an error. (djangoenv) E:\youngminds>heroku run bash Running bash on ? youngminds... up, run.8229 (Free) ~ $ python manage.py createsuperuser Username (leave blank to use 'u21088'): johnson Email address: johnson@gmail.com Password: Password (again): Traceback (most recent call last): File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils .py", line 85, in _execute return self.cursor.execute(sql, params) psycopg2.errors.UndefinedTable: relation "users_profile" does not exist LINE 1: INSERT INTO "users_profile" ("user_id", "image", "descriptio... ^ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/_ _init__.py", line 371, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/_ _init__.py", line 365, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/b ase.py", line 288, in run_from_argv self.execute(*args, **cmd_options) File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/auth/mana gement/commands/createsuperuser.py", line 59, in execute return super().execute(*args, **options) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/b ase.py", line 335, in execute output = self.handle(*args, **options) File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/auth/mana gement/commands/createsuperuser.py", line 179, in handle self.UserModel._default_manager.db_manager(database).create_superuser(**user _data) File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/auth/mode ls.py", line 161, in create_superuser return self._create_user(username, email, password, … -
create facebook like notification system in django
Say user a liked user b. I want to show this as a notification in the notification panel of user b when she logs in. She can also view her previous notifications (basically like facebook notification). This is not email notification or a success/warning type one time notification. I want to know the right track to follow. Do I use django-notifications or django-messages-framework? Where is the use of channels and web sockets in all of these? My steps: 1) create a notification app 2) create a notification model (what fields do I put here if since django-notification already has actor, verb, action object and target fields?) 3) Do i have to create forms.py? How is the notification message getting passed? 4) What view do I put in views.py? (please give an example code) If there is any example project that implemented the notification system please provide a link.