Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Is there a way reach to grandchild count with related name in django?
I have several models like that; class Survey(models.Model): name = models.CharField(max_length=200, null=False) class SurveyCollector(models.Model): survey = models.ForeignKey(Survey, on_delete=models.CASCADE, related_name='survey_collector_survey') class SurveyResponse(models.Model): collector = models.ForeignKey(SurveyCollector, on_delete=models.CASCADE, related_name='surveyresponse_collector') and i would like to display survey responses count in the survey_list.html. My template code seems like that; {% for survey in surveys %} <tr> <th scope="row">{{ survey.name }}</th> <td align="center">{{ survey.survey_collector_survey.count }}</td> </tr> {% endfor %} I can get surveys collectors with above code. But i cannot get true result when i try this code <td align="center">{{ survey.survey_collector_survey.surveyresponse_collector.count }}</td> I couldnt find right approach. Could you please help me to find the best way? -
How make registration and log in option for Django API without the use of forms/HTML?
I have made an API using Django that displays school subjects for student. I wish to modify this API in such a way that student can only view the modules/data if they are logged in to the API. The API has no front-end/html/css. How can I make a registration option that does not require a html form but can simply read JSON data provided by a POST request from a client (For example "Postman"). Where the POST request for registration would be sent to localhost:test/register and would contain something like: {"username":"...","password1":"...","password2":"..."} and the POST request for log in would be sent to localhost:test/login and would contain something like: {"username":"...","password":"..."} -
Filter items according to Foreign Key
I have a model called Destination, each Destination has it's own certain Bucket Lists (DestinationBucketlist model) related to that Destination. What I want to do is in Bucket List Detail page show the list of related Bucket List items belonging for the same Destination. In other words I want to filter them according to the Destination. I tried multiple examples, but the problem is that either I get the list of all existing Bucket List items despite the Destination or it shows nothing... I think there should be something in my views.py but I can't figure out what I am missing. Here is bit of my code models.py: class Destination(models.Model): destination = models.CharField(max_length=200) description = RichTextField() main_photo = models.ImageField(blank=True, null=True) tags = TaggableManager() def get_absolute_url(self): return reverse("destination_detail", kwargs={'pk': self.pk}) def __str__(self): return self.destination class DestinationBucketList(models.Model): place_name = models.CharField(max_length=200) photo = models.ImageField(blank=True, null=True) description = RichTextUploadingField(blank=True, null=True) tips_desc = RichTextUploadingField(blank=True, null=True) description2 = RichTextUploadingField(blank=True, null=True) destination = models.ForeignKey(Destination, related_name="destination_bucketlist", on_delete=models.CASCADE) views.py: class DestinationDetailView(DetailView): model = Destination template_name ='WSE_blog/destination_detail.html' context_object_name = 'destination' def get_context_data(self, **kwargs): context = super(DestinationDetailView, self).get_context_data(**kwargs) context['destination'] = self.object context['post'] = self.object context['destinations_list'] = DestinationList.objects.all() context['destinations_detail'] = DestinationDetail.objects.filter(destination=self.object) context['bucket_list'] = DestinationBucketList.objects.filter(destination=self.object) context['related_articles'] = self.object.tags.similar_objects()[:4] return context class BucketlistDetailView(DetailView): model … -
Django project run broker and woker in remote host
I have a Django project, and it runs celery using Rabbitmq as a broker in a remote server. I wonder if I can run worker on the remote server too. I do not want to run broker and worker in one remote server, but run it on seperated remote server. I wonder if this is possible. -
Django. Where to put custom methods in models.py?
I put some logic into custom methods in my model. I did it for using those methods in views My model: class Quiz(models.Model): # Some fields.. # And some example methods that contain a logic def get_manage_questions_url(self): return reverse('manage-questions', kwargs={'slug': self.slug}) def get_likes_count(self): return self.likes.count() def get_completed_count(self): return QuizManager.objects.filter(quiz=self, completed=True).count() def like_quiz(self, quiz, user): data = {} if user in quiz.likes.all(): quiz.likes.remove(user) data['liked'] = False else: quiz.likes.add(user) data['liked'] = True data['likes'] = quiz.get_likes_count() return data def increase_views(self): self.views += 1 self.save(update_fields=('views',)) I have a question: Do I need to write all custom methods in the model or I need to put methods like these into a manager kind of QuizManager(models.Manager) and define "objects" attribute in the quiz model? -
Django: Model class __main__.Source doesn't declare an explicit app_label when loading a model in PyCharm
I used to load models in Python shell in PyCharm with no error before, but now it through this error Traceback (most recent call last): File "<input>", line 12, in <module> File "C:\...\lib\site-packages\django\db\models\base.py", line 112, in __new__ raise RuntimeError( RuntimeError: Model class __main__.Source doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS. I checked similar questions such as this and this and followed the proposed answers with no success. Funny thing is that python manage.py runserver doesn't through any error and website load smoothly. The only change to my environment is that update for windows I got yesterday. I already have app name for all of my apps, set the DJANGO_SETTINGS_MODULE and all imports are absolute. -
Testing Django Activation email with selenium / pytest. EMAIL_BACKEND="django.core.mail.backends.filebased.EmailBackend"
I'm trying to write a function that tests activation email send by selenium Firefox client. Activation Emails are successfully written as files under "tests/test_selenium/outbox" directory, but I"m not able to handle email in test_activation_email() method. Django==2.2 pytest-django==3.8.0 settings.py EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend' EMAIL_FILE_PATH = os.path.join(BASE_DIR, "tests", "test_selenium", "outbox") test_registration.py import pytest, time, os from django.core import mail from src import settings from yaml import safe_load from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.desired_capabilities import DesiredCapabilities # firefox driver from selenium.webdriver.firefox.options import Options from selenium.webdriver.firefox.firefox_profile import FirefoxProfile from selenium.webdriver.firefox.firefox_binary import FirefoxBinary @pytest.mark.django_db(transaction=True) class TestCreateAccount(): t_username = "Pesho" t_password = "alabala" t_perm_email_1 = "pesho@example.com" t_perm_email_2 = "pesho@example.com" t_denied_email = "pesho@gmail.com" def setup_method(self, method): # Load config and check/download browser driver config_file = 'tests/test_selenium/selenium_config.yml' with open(config_file) as ymlfile: cfg = safe_load(ymlfile) # Firefox headless option options = Options() if cfg['HEADLESS_BROWSER']: options.headless=True if cfg['BROWSER'].lower() == 'firefox': # check if driver is downloaded try: if os.path.isfile(cfg['SELENIUM_DRIVER_FF_BIN']): print(f"Driver {cfg['SELENIUM_DRIVER_FF_BIN']} found") except Exception as e: raise(f'Driver not found: {e} run selenium_downloader.py first') self.driver = webdriver.Firefox( options=options, # firefox_profile = ff_profile, # capabilities=firefox_capabilities, # firefox_binary=binary, executable_path=cfg['SELENIUM_DRIVER_FF_BIN']) elif cfg['BROWSER'].lower() == … -
Bookdown for Django/Python?
Is there a package or an open source project similar to Bookdown (from R) for Django/Python? I need to replicate this books / page: https://ggplot2-book.org/ Witch chapters, etc... and have also user uthentication, etc. -
Get children models not passing to database in django
Having these two models: class Campaign(models.Model): id = models.AutoField(primary_key=True) class AdGroup(models.Mode): id = models.AutoField(primary_key=True) campaign = models.ForeignKey(Campaign, related_name='ad_groups', on_delete=models.PROTECT) There is a way to access to the campaign children without create the row in the db? c = Campaign() a1 = AdGroup(campaign=c) a2 = AdGroup(campaign=c) for ad_group in c.ad_groups: do_something() -
SESSION_EXPIRE_AT_BROWSER_CLOSE not working
I'm trying to close the session when the user closes the browser or the tab. I saw that SESSION_EXPIRE_AT_BROWSER_CLOSE is supposed to do that. However it doesn't seem to work. I have successfully implemented the session_security plugin (as suggested in this answer). My settings look as follows: SESSION_SAVE_EVERY_REQUEST = True SESSION_EXPIRE_AT_BROWSER_CLOSE = True SESSION_SECURITY_WARN_AFTER = 120 SESSION_SECURITY_EXPIRE_AFTER = 240 I've tried both with SESSION_SAVE_EVERY_REQUEST set to Trueand False, but the session is still open when I relaunch the browser. Any tips? -
cannnot get article to template
hello guys I want to create post list with 2 col mid i upload the picture and you can see my problem exactly. I have to lines of post-left and right side with images but when I'm uploading post on left is only one art and on the right side, there is 4 article and when I want to add the new article it's should be the second on left side column but it's replacing latest article enter image description here my template code {% for post in postlist %} <!-- POST PREVIEW --> <div class="post-preview medium movie-news"> <!-- POST PREVIEW IMG WRAP --> <a href="post-v3.html"> <div class="post-preview-img-wrap"> <!-- POST PREVIEW IMG --> <figure class="post-preview-img liquid"> <img src="{{ post.Post_image.url }}" alt="post-03"> </figure> <!-- POST PREVIEW IMG --> </div> </a> <!-- /POST PREVIEW IMG WRAP --> <!-- TAG ORNAMENT --> <a href="news-v3.html" class="tag-ornament">{{ post.category }}</a> <!-- /TAG ORNAMENT --> <!-- POST PREVIEW TITLE --> <a href="post-v3.html" class="post-preview-title">{{ post.Post_title }} </a> <!-- POST AUTHOR INFO --> <div class="post-author-info-wrap"> <!-- USER AVATAR --> <a href="search-results.html"> <figure class="user-avatar tiny liquid"> <img src="{{ post.Post_image.url }}" alt="user-03"> </figure> </a> <!-- /USER AVATAR --> <p class="post-author-info small light">ავტორი <a href="search-results.html" class="post-author">{{ post.Post_author }}</a> <span class="separator">|</span>{{ post.Post_created_on }}<span … -
I want to run django and php site on one ip and port?
My local ip is 192.168.29.248. And i want to run php site normally when i run 192.168.29.248:8086 and django website as 192.168.29.248:8086/django/.How can I achieve this? My current vhosts.conf is: <VirtualHost *:8086> ServerName localhost ServerAlias localhost DocumentRoot "${INSTALL_DIR}/www" <Directory "${INSTALL_DIR}/www/"> Options +Indexes +Includes +FollowSymLinks +MultiViews AllowOverride All Require all granted </Directory> </VirtualHost> Please help? -
Django Zappa Lambda Deploy "botocore.errorfactory.ResourceNotFoundException"
I am trying to deploy simple django application from zappa (https://romandc.com/zappa-django-guide/) I am getting the following error. Is there any permission issue or some other issue with the dev setup? Traceback (most recent call last): File "e:\personal\envs\py3\lib\site-packages\zappa\cli.py", line 753, in deploy function_name=self.lambda_name) File "e:\personal\envs\py3\lib\site-packages\zappa\core.py", line 1286, in get_lambda_function FunctionName=function_name) File "e:\personal\envs\py3\lib\site-packages\botocore\client.py", line 314, in _api_call return self._make_api_call(operation_name, kwargs) File "e:\personal\envs\py3\lib\site-packages\botocore\client.py", line 612, in _make_api_call raise error_class(parsed_response, operation_name) botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the GetFunction operation: Function not found: arn:aws:lambda:ap-south-1:122866061462:function:frankie-dev During handling of the above exception, another exception occurred: Traceback (most recent call last): File "e:\personal\envs\py3\lib\site-packages\zappa\cli.py", line 2778, in handle sys.exit(cli.handle()) File "e:\personal\envs\py3\lib\site-packages\zappa\cli.py", line 512, in handle self.dispatch_command(self.command, stage) File "e:\personal\envs\py3\lib\site-packages\zappa\cli.py", line 549, in dispatch_command self.deploy(self.vargs['zip']) File "e:\personal\envs\py3\lib\site-packages\zappa\cli.py", line 786, in deploy self.lambda_arn = self.zappa.create_lambda_function(**kwargs) File "e:\personal\envs\py3\lib\site-packages\zappa\core.py", line 1069, in create_lambda_function response = self.lambda_client.create_function(**kwargs) File "e:\personal\envs\py3\lib\site-packages\botocore\client.py", line 314, in _api_call return self._make_api_call(operation_name, kwargs) File "e:\personal\envs\py3\lib\site-packages\botocore\client.py", line 586, in _make_api_call api_params, operation_model, context=request_context) File "e:\personal\envs\py3\lib\site-packages\botocore\client.py", line 641, in _convert_to_request_dict api_params, operation_model) File "e:\personal\envs\py3\lib\site-packages\botocore\validate.py", line 291, in serialize_to_request raise ParamValidationError(report=report.generate_report()) botocore.exceptions.ParamValidationError: Parameter validation failed: Unknown parameter in input: "Layers", must be one of: FunctionName, Runtime, Role, Handler, Code, Description, Timeout, MemorySize, Publish, VpcConfig, DeadLetterConfig, Environment, KMSKeyArn, TracingConfig, Tags -
How to automate the coverage report generation and rendering?
I am trying to automate the coverage report generation such that there would be a URL which when hit the corresponding view should generate the coverage report and render the coverage report. I have done the same via command line operation, such that on giving the command to run coverage tests, it would generate the report and mail the generated report. Can I do the same via a URL where the corresponding view would run the command for coverage report and render it as an HTML?? -
Django weighted query
I have a query in Django which I order by the last updated timestamp and returns me a queryset of Orders which currently returns based on the timestamp a supplier last updated. The query is currently a simple select with ordering Order.objects.filter(fulfilled=False).order_by('updated') Currently I have id, updated, supplier 1 2019-03-03 10:00 ABC 2 2019-03-03 10:00 ABC 3 2019-03-03 10:00 ABC 4 2019-03-03 12:00 DEF 5 2019-03-03 12:00 DEF 6 2019-03-03 12:00 DEF How will I achieve a result that's ordered by updated but also by supplier. id, updated, supplier 1 2019-03-03 10:00 ABC 4 2019-03-03 12:00 DEF 2 2019-03-03 10:00 ABC 5 2019-03-03 12:00 DEF 3 2019-03-03 10:00 ABC 6 2019-03-03 12:00 DEF -
zsh: abort pipenv shell
On attempts to install psycopg2, postgresql, django-Heroku, gunicorn, I am now getting the below error. Unable to successfully run pipenv shell or pipenv install; can't run python manage.py runserver, which means I can't open my project! Appreciate anyone who can reach out with fix for this issue. dyld: Library not loaded: @executable_path/../.Python Referenced from: /usr/local/Cellar/pipenv/2018.11.26_3/libexec/bin/python3.8 Reason: image not found zsh: abort pipenv shell -
Why am I getting IntegrityError at /signup/taxpayer/ NOT NULL constraint failed: accounts_taxpayer.aadhar
from django import forms from .models import User, TaxpayerProfile, OfficialProfile class UserForm(forms.ModelForm): class Meta: model = User fields = ['first_name', 'last_name', 'email'] class TaxpayerProfileForm(forms.ModelForm): class Meta: model = TaxpayerProfile fields = ['aadhar'] class OfficialProfileForm(forms.ModelForm): class Meta: model = OfficialProfile fields = ['aadhar', 'uid'] Above is the forms.py file Below is the views.py file from django.contrib.auth import login from django.shortcuts import redirect, render from django.http import HttpResponse, HttpResponseRedirect from django.views.generic import CreateView from .forms import OfficialProfileForm, TaxpayerProfileForm, UserForm from .models import User def taxpayer_profile_view(request): if request.method == 'POST': user_form = UserForm(request.POST) taxpayer_profile_form = TaxpayerProfileForm(request.POST) if user_form.is_valid() and taxpayer_profile_form.is_valid(): user = user_form.save(commit=False) user.save() user.taxpayer_profile.aadhar = taxpayer_profile_form.cleaned__data.get('aadhar') user.taxpayer_profile.save() return HttpResponseRedirect('/thanks/') else: user_form = UserForm() taxpayer_profile_form = TaxpayerProfileForm() return render(request, 'accounts/taxpayer_profile.html', {'user_form':user_form, 'taxpayer_profile_form':taxpayer_profile_form}) else: user_form = UserForm() taxpayer_profile_form = TaxpayerProfileForm() return render(request, 'accounts/taxpayer_profile.html', {'user_form':user_form, 'taxpayer_profile_form':taxpayer_profile_form}) def official_profile_view(request): if request.method == 'POST': user_form = UserForm(request.POST) official_profile_form = OfficialProfileForm(request.POST) if user_form.is_valid() and official_profile_form.is_valid(): user = user_form.save(commit=False) user.save() user.official_profile.aadhar = official_profile_form.cleaned__data.get('aadhar') user.official_profile.uid = official_profile_form.cleaned__data.get('uid') user.official_profile.save() return HttpResponseRedirect('/thanks/') else: user_form = UserForm() official_profile_form = OfficialProfileForm() return render(request, 'official_profile.html', {'user_form':user_form, 'official_profile_form':official_profile_form}) else: user_form = UserForm() official_profile_form = OfficialProfileForm() return render(request, 'officialr_profile.html', {'user_form':user_form, 'official_profile_form':official_profile_form}) I have included the proper url path in my urls file and the models have fields … -
How to parse data from website at the touch of a button from /admin. Django
I wrote aa simple parser which takes books authors from website and load them to DataBase. But i have some questions: -Where to place it (I gues in models.py)? -How to write it better (I made class, may be it isn't best way)? -How to call it at the touch of a button from /admin? Here it is: class Parsing: def __init__(self, page): self.page = page self.html_doc = urlopen(f'https://www.litmir.me/bs?rs=5%7C1%7C0&o=20&p={self.page}').read() self.soup = BeautifulSoup(self.html_doc) self.cards = self.soup.find_all('div', itemtype='http://schema.org/Book') def get_author(self, card): return card.find('span', itemprop='author').find_all('a')[0].get_text() def load_authors(self): for card in self.cards: Author.objects.create(f'{self.get_author(card)}') -
Django and alwaysdata: internationalization not applied
I developed a Django application that I deployed in tests on alwaysdata The application is easily accessible but internationalization does not apply However, I did 'execute' the internationalization during the deployment in my virtual environnement (/home/mereva/intensetbm-etool) (django-admin makemessages -l fr and django-admin compilesmessages) and I don't have an error message (normal command return) Locally, I have no problem, my site is well translated into French when the web browser is in French ... Deployment on alwaysdata is not trivial ... architecture of my project: /home/mereva/envTbm (virtual environment) /home/mereva/intensetbm-etool (project folder containing manage.py) /home/mereva/intensetbm_static (static file) /home/mereva/intensetbm-etool/intenseTBM_eTool/settings.py (root of the project containing settings.py) /home/mereva/intensetbm-etool/locale (Django translation file) settings.py import os import psycopg2.extensions # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'rqps9azjw7i0@_(qxirwr!@0w3f)$prsky9l7bt8t-(y)_tiuj' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False # ALLOWED_HOSTS = ['127.0.0.1','localhost', '[::1]'] ALLOWED_HOSTS = ['mereva.alwaysdata.net'] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'crispy_forms', 'widget_tweaks', 'bootstrap4', 'registration.apps.RegistrationConfig', 'monitor.apps.MonitorConfig', 'randomization.apps.RandomizationConfig', 'parameters.apps.ParametersConfig', 'unblind.apps.UnblindConfig', 'pharmacy.apps.PharmacyConfig', 'export.apps.ExportConfig', 'django_extensions', # 'debug_toolbar', 'partial_date', 'safedelete', 'simple_history', ] … -
Django: settings for tests of a reusable app?
I created a small app in Django and runserver and admin works fine. I wrote some tests which can call with python manage.py test and the tests pass. Now I would like to call one particular test via PyCharm. This fails like this: /home/guettli/x/venv/bin/python /snap/pycharm-community/179/plugins/python-ce/helpers/pycharm/_jb_pytest_runner.py --path /home/guettli/x/xyz/tests.py Launching pytest with arguments /home/guettli/x/xyz/tests.py in /home/guettli/x ============================= test session starts ============================== platform linux -- Python 3.6.9, pytest-5.4.1, py-1.8.1, pluggy-0.13.1 -- cachedir: .pytest_cache rootdir: /home/guettli/x collecting ... xyz/tests.py:None (xyz/tests.py) xyz/tests.py:6: in <module> from . import views xyz/views.py:5: in <module> from xyz.models import Term, SearchLog, GlobalConfig xyz/models.py:1: in <module> from django.contrib.auth.models import User venv/lib/python3.6/site-packages/django/contrib/auth/models.py:2: in <module> from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager venv/lib/python3.6/site-packages/django/contrib/auth/base_user.py:47: in <module> class AbstractBaseUser(models.Model): venv/lib/python3.6/site-packages/django/db/models/base.py:107: in __new__ app_config = apps.get_containing_app_config(module) venv/lib/python3.6/site-packages/django/apps/registry.py:252: in get_containing_app_config self.check_apps_ready() venv/lib/python3.6/site-packages/django/apps/registry.py:134: in check_apps_ready settings.INSTALLED_APPS venv/lib/python3.6/site-packages/django/conf/__init__.py:76: in __getattr__ self._setup(name) venv/lib/python3.6/site-packages/django/conf/__init__.py:61: in _setup % (desc, ENVIRONMENT_VARIABLE)) E django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. Assertion failed collected 0 items / 1 error I understand the background: My app xyz is reusable. It does not contain any settings. The app does not know (and should not know) my project. But the settings are in my … -
Call a python function in Django and display the results on the same page
I'm a beginner to django and I'm trying to perform a cipher operation, but what I want to do is whenever I press the cipher button it should compute the logic and display the results on the same page i.e. my homepage. It'd be really great if someone could help me out. This is my html template ''' <h1>PRODUCT CIPHER</h1> <form action=""> <label> Enter Message Here: <input name="message" type="text"><br><br> Enter key for Shift: <input name="shiftKey" type="number"><br><br> Enter key for transpose: <input name="transKey" type="number"><br> For transposition 1->Reverse and 2->Even Odd<br><br> </label> <input type="submit" value="Encrypt" name="Encrypt"><br> <p>{{ encrypted_message }}</p><br> <input type="submit" value="Decrypt" name="Decrypt"> <p>{{ decrypted_message }}</p> </form> Thanks in advance -
How to make Django API with registration and login
I am trying to make an API in Django that returns employee info as JSON only when a user is logged in. I want to make a way for users to register and log in only via a client or via the link, for example: localhost:examplelink/registration_email_username_password... I do not know how to do this without the use of a html form. Is it possible? -
Displaying random items from table
I am trying to display 3 random items from my database in my product page. I have created a function in my models: class Item(models.Model): title = models.CharField(max_length=100) price = models.FloatField() discount_price = models.FloatField(blank=True, null=True) label = models.ManyToManyField(Label, blank=True) slug = models.SlugField(unique=True) description = models.TextField() def random(self): count = self.aggregate(count=Count('id'))['count'] random_index = randint(0, count - 1) return self.all()[random_index] My views: def random_items(request): random = Item.objects.random() return render(request, "product.html", {'random': random}) and the product page: {% for item in random %} <div class="col-lg-3 col-md-6 mb-4 d-flex align-items-stretch "> <div class="card"> <div class="view overlay "> <img src="{{ item.image.url }} " class="card-img-top"> </div> </div> </div> {% endfor %} I am getting no image, any suggestions? -
Automatic React build for Django server
I know there is probably a simple solution to this but I was not able to find anything. I am using VSCode and have a front end in React and backend in Django, but currently, whenever I make a change in the front end it seems like I need to rebuild everything for the changes to appear in the Django server. Is there any way I can automate this so I don't need to build every small change I make? -
Missing '/' in static path using django and nginx
I'm very new to django and nginx. When hitting /domain/admin The admin page loads but without css. After checking the logs by hitting this command tail -30 /var/log/nginx/error.log output: /usr/local/apps/appname/staticrest_framework/js/prettify-min.js I've found out that / is missing in the staticrest_framework the expected output should be /usr/local/apps/appname/static/rest_framework/js/prettify-min.js Here is my settings.py: STATIC_URL = '/static/' STATIC_ROOT = '/usr/local/apps/appname/static/' nginx config: server { listen 80 default_server; location /static/ { alias /usr/local/apps/appname/static/; } location / { proxy_pass http://127.0.0.1:9000/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_redirect off; } } Please help, how do I add / in the middle of static and rest_framework path?