Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Dockerized Django app not allowing connections
I have a Django project that im trying to dockerize. When I run the the docker image i get no errors and the django app says it waiting for connections. Navigating to localhost, 127.0.0.1, or my VMs ip return no connection and the Django terminal reports no incoming connections. this is how i build and run my docker image docker build -t 0rion447/osas:osas_latest docker run -it -p 80:8000 0rion447/osas:osas_latest here is my dockerfile FROM python:3.8.5 COPY requirements.txt ./ RUN pip3 install --user -r requirements.txt RUN pip3 install psycopg2-binary RUN python3 -m pip install --upgrade Pillow COPY . app COPY run_server.sh ./ RUN chmod +x run_server.sh EXPOSE 8000 ENTRYPOINT ["./run_server.sh"] and my run_server.sh #!/bin/sh python app/manage.py runserver 0.0.0.0:8000 In my settings.py i have ALLOWED_HOSTS['*'] Let me know if you need any other information. -
Fetching data from an api and adding to a database in Django
I'm working on a project where I need to update values based on whether a user adds/deletes them. But, the original data is from an api, and I want to store that in a Django database. How do I do that without repeatedly making calls to the api? In other words, I just want to include the data from the api in my database in the beginning, and then modify it accordingly based on what the user decides to add/delete in the future without having to fetch that api over and over to check if its data exists in the database or not as that is unnecessary. -
How to know customer new payment date is arrived in Django?
Info I am trying to make monthly subscription based like app. Where a customer can buy a property on a monthly basis payment. The customer will continue to pay a certain amount for the property each month until the value of the property is paid. Everthing is working fine now i want to know how can i check which customers new payment date is arrived and how do I filter out customers who haven't made a new payment yet? models.py class Property(models.Model): """Property Model""" area = models.CharField(max_length=255) price = models.DecimalField(max_digits=17, decimal_places=2, default=0.0,) created_on = models.DateTimeField(auto_now_add=True) class Customer(models.Model): """Customer Model""" name = models.CharField(max_length=255) prop_select = models.ForeignKey(Property, on_delete=models.SET_NULL, null=True) created_on = models.DateTimeField(auto_now_add=True) remaning_amount = models.DecimalField(max_digits=17, decimal_places=2, default=0.0) def save(self, *args, **kwargs): property_price = self.prop_select.price payment_done_by_customer = Payment.objects.filter(customer=self).aggregate(Sum('amount'))['amount__sum'] or Decimal('0') # Remaining Amount of each customer self.remaning_amount = property_price - payment_done_by_customer super(Customer, self).save(*args, **kwargs) class Payment(models.Model): """Payment Model""" customer = models.ForeignKey(Customer, null=True, on_delete=models.SET_NULL, related_name='payment') datetime = models.DateTimeField(auto_now_add=True) amount = models.DecimalField(max_digits=17, decimal_places=2, default=0.0) -
How can I fix KeyError: 'ariadne_jwt'?
Sometimes when I attempt to runserver I get the following error and I cant figure out the cause. It used to show up every few times I boot up my Django project but now its occurring every-time and I cant seem to figure out why. I have tried restarting the server, clearing pyCache, updating my packages, uninstalling the ariadne_jwt and reinstalling it but its not working. Terminal output Exception in thread django-main-thread: Traceback (most recent call last): File "/Users/chuksgrinage/.pyenv/versions/3.9.6/lib/python3.9/threading.py", line 973, in _bootstrap_inner self.run() File "/Users/chuksgrinage/.pyenv/versions/3.9.6/lib/python3.9/threading.py", line 910, in run self._target(*self._args, **self._kwargs) File "/Users/chuksgrinage/Desktop/Projects/Next/pinkle/backend/venv/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "/Users/chuksgrinage/Desktop/Projects/Next/pinkle/backend/venv/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 118, in inner_run self.check(display_num_errors=True) File "/Users/chuksgrinage/Desktop/Projects/Next/pinkle/backend/venv/lib/python3.9/site-packages/django/core/management/base.py", line 419, in check all_issues = checks.run_checks( File "/Users/chuksgrinage/Desktop/Projects/Next/pinkle/backend/venv/lib/python3.9/site-packages/django/core/checks/registry.py", line 76, in run_checks new_errors = check(app_configs=app_configs, databases=databases) File "/Users/chuksgrinage/Desktop/Projects/Next/pinkle/backend/venv/lib/python3.9/site-packages/django/contrib/admin/checks.py", line 125, in check_dependencies if not _contains_subclass('django.contrib.messages.middleware.MessageMiddleware', settings.MIDDLEWARE): File "/Users/chuksgrinage/Desktop/Projects/Next/pinkle/backend/venv/lib/python3.9/site-packages/django/contrib/admin/checks.py", line 41, in _contains_subclass candidate_cls = import_string(path) File "/Users/chuksgrinage/Desktop/Projects/Next/pinkle/backend/venv/lib/python3.9/site-packages/django/utils/module_loading.py", line 17, in import_string module = import_module(module_path) File "/Users/chuksgrinage/.pyenv/versions/3.9.6/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 850, in exec_module File … -
Getting text of HTML element and passing it to django view using AJAX
I have the following paragraph: <p>{{donation.pk}}</p>. I want to pass the value of the paragraph into the view bellow as a pk def acceptdonation(request, pk): #the `pk` should be the `pk` of the `p` element deleteitem = Donation.objects.filter(id = pk) deleteitem.delete() return redirect('/dashboard/') I did research, and heard that you need to use AJAX. How exactly can I achieve this. I am not to good with javascript so the easiest and most minimalist way would be helpful. PLEASE NOTE: I already have a button that calls the view, I just want to pass the value of the p element into my function -
Change response to JsonResponse in Class-based view
I'm using curl to submit form data to my website. curl -F some_file=@file.txt -F name=test_01 https://localhost:8000 It's not an API but I have a requirement for a single endpoint that behaves as an API. I'm a little out of my depth here, so I'm hoping someone can help me. I've got the model set up and working and the CreateView, as well: class CreateFile(CreateView): model = SomeFile fields = ['name', 'some_file', . . .] When I send a POST request with curl as above to the specified URL (/file/request), the object is created in the DB and I get a response (set to /thanks now which is a generic templated HTML rendered file). But since a non-browser will be sending this request, I was hoping to respond with some JSON. Maybe with the object's name, status, etc. I've tried a few things with mixed results... For example, if I use View instead of CreateView, I can return JSON but I really like the ease and convenience of the CreateView CBV, so I'm hoping I can do what I want this way. How can I do this? -
Using Django tests on model validation, how to test that a value does not raise a validation error
I know that I can check if a validation error will be raised like so: ` def test_validate_fee_range(self): test = Foo.objects.get(name="T1") test.full_clean() test.fee = 105 # raise Validation error for value less than 0 and greater than 100 self.assertRaises(ValidationError, test.full_clean)` For completeness I want to test that values between 0 and 100 do not raise a ValidationError. How do I do this? -
Django DRF, how to properly register custom URL patterns with DRF actions
Background I have a ModelViewSet that defines several custom actions. I am using the default router in my urls.py to register the URLs. Right now, my views use the default created routes like ^images/$, ^images/{pk}/$. In order for users to use the API using resource names with which they are familiar, I have adapted the viewset to accept multiple parameters from the URL, using the MultipleFieldLookupMixin strategy described in the docs to allow for the pattern images/{registry_host}/{repository_name}/{tag_name}. I've created the get_object method in my viewset like so: class ImageViewSet(viewsets.ModelViewSet): ... def get_object(self): special_lookup_kwargs = ['registry_host', 'repository_name', 'tag_name'] if all(arg in self.kwargs for arg in special_lookup_kwargs): # detected the custom URL pattern; return the specified object return Image.objects.from_special_lookup(**self.kwargs) else: # must have received pk instead; delegate to superclass return super().get_object() I've also added a new URL path pattern for this: urls.py router = routers.DefaultRouter() router.register(r'images', views.ImageViewSet) # register other viewsets ... urlpatterns = [ ..., path('^images/<str:registry_host>/<path:repository_name>/<str:tag_name>', views.ImageViewSet.as_view({'get': 'retrieve',})), path('', include(router.urls)), ] Problem The above all works as intended, however, I also have some extra actions in this model viewset: @action(detail=True, methods=['GET']) def bases(self, request, pk=None): ... @action(detail=True, methods=['GET']) def another_action(...): ... # and so on With the default patterns registered by … -
How do i upload an image into database as base64 in django?
This is my Code. Model Form And View........ class Home(models.Model): title = models.CharField(max_length=250) image = models.FileField() content = models.CharField(max_length=5000000) date_created = models.DateTimeField(auto_now_add=True) is_deleted = models.BooleanField() class Meta: db_table = 'home' #model class HomeForm(forms.ModelForm): class Meta: model = Home fields = '__all__' title = forms.CharField(label="title") image = forms.FileField(label="image") content = forms.CharField(label="content") #form def HomePage(request): home = Home.objects.order_by('-id') form = HomeForm() if request.method == 'POST': # print(request.POST) form = HomeForm(request.POST, request.FILES or None) if form.is_valid(): image = form.cleaned_data['image'] b64_img = base64.b64encode(image.file.read()) form.save() #model Please What am i doing wrong? How do i upload an image into database as base64 in django ?? -
Why is my django project only working properly on Chrome but not Edge nor Safari?
I was working on my landing page for my project and I was doing it all in Chrome but then I wanted open it in Edge and it does not seem like it can find my static files. My page looks all messy in Edge and I get the following in the terminal: On Crome there is no error and that is the weird part for me. Here is the structure of my files: I see it cannot find the files and django has a way of using static files and the way I called each static file is <link href="{%static 'vendor/bootstrap/css/bootstrap.min.css'%}" rel="stylesheet" /> or <script src="{%static 'vendor/bootstrap/js/bootstrap.bundle.min.js'%}"></script>. I have no idea how I got here or if I am doing something wrong so any feedback would be appreciated. -
django collectstatic 'AppConfig' object has no attribute 'ignore_patterns'
I recently upgraded django to 3.2.5, after which admin template was not loading correctly especially in model pages, please see the screenshot, I decided to run, python manage.py collectstatic but then I am receiving following error Traceback (most recent call last): File "/var/www/dev.bluelion.icu/bluelion/manage.py", line 21, in main() File "/var/www/dev.bluelion.icu/bluelion/manage.py", line 17, in main execute_from_command_line(sys.argv) File "/var/www/dev.bluelion.icu/bluelion/bluelionenv/lib/python3.9/site-packages/django/core/management/init.py", line 419, in execute_from_command_line utility.execute() File "/var/www/dev.bluelion.icu/bluelion/bluelionenv/lib/python3.9/site-packages/django/core/management/init.py", line 413, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/var/www/dev.bluelion.icu/bluelion/bluelionenv/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv self.execute(*args, **cmd_options) File "/var/www/dev.bluelion.icu/bluelion/bluelionenv/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute output = self.handle(*args, **options) File "/var/www/dev.bluelion.icu/bluelion/bluelionenv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 149, in handle self.set_options(**options) File "/var/www/dev.bluelion.icu/bluelion/bluelionenv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 82, in set_options ignore_patterns += apps.get_app_config('staticfiles').ignore_patterns AttributeError: 'AppConfig' object has no attribute 'ignore_patterns' Any help is appreciated, please let me know if there is any ambiguity in the question! -
form doesnt dave, but adds a weird string into the url
following a Django tutorial, i coded the following html file that takes a form filled by a user and adds it to the database as an object (the form is a bunch of attributes of a class) {% block content %} <form> <form method="POST"> {% csrf_token %} {{ form.as_p }} <input type='submit' value = 'save' /> </form> {% endblock %} instead of saving the form to the database, it adds a weird string to the url (pasted below). this happened to the guy in the tutorial, but it was fixed after he added the <form method="POST"> {% csrf_token %} what is this "error", and how can i deal with it? also, what can i do if it happens in the future? there's no real error, the server goes on fine, so there's no traceback/error message to show. i made sure the form.as_p is a real variable, and that there's no typos in the variables or tags relative to the tutorial. only problem i can think of is the change in versions - the tutorial is in Django 2.0.7 and i am on 3.2.5, but the csrf_token is still valid according to what i saw in the docs. added to the … -
How to set a specific time zone in django?
In django, it only has UTC timezone and other countries, but I live in Texas and there's like a five hour difference. How do I specify central time zone in my settings.py? -
How to direct a python package to a user install library rather than a root library?
I install python packages to my user root directory since I can't install it to the root directory due to security issues. The python package (pyobdc) is looking for /usr/local/lib/libmsodbcsql.13.dylib which doesn't exist there but it exists at /Users/Max/usr/local/lib/libmsodbcsql.13.dylib. I wanted to create a syslink but of course I ran into the same issue which is permissions to root. How can I make the package (Installed in a Django project) point to the user root? -
Exception Value: name 'VideoThumbnailUrl' is not defined
I'm trying to fetch information from videos on youtube using youtube-dl, the problem is when I try to store the information on the DB, When I run my script I'm getting the next error: Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/FullStack/views.py", line 209, in getVideoData Video.objects.create(VideoThumbnailURL=VideoThumbnail) Exception Type: NameError at /getvideodata Exception Value: name 'VideoThumbnailUrl' is not defined My code: views.py from .models import Video def getvideodata(request): if 'url' in request.POST: VideoThumbnail = get_thumbnail(request.POST['url']) # works fine, returns the thumbnail URL Video.objects.create(VideoThumbnailURL=VideoThumbnail) # problem here models.py class Video(models.Model): VideoID = models.UUIDField(default=uuid.uuid4,null=False,primary_key=True,blank=False,editable=False, unique=True) VideoThumbnailURL = models.CharField(max_length=100,null=True,blank=True) The problem I'm seeing is that I'm using VideoThumbnailURL but Python is taking as VideoThumbnailUrl it's lower casing the last part of the variable. Any thoughts on this? Thanks -
Getting a django.contrib.gis.gdal.error - GDAL OGR error
I am getting the following error django.contrib.gis.gdal.error.GDALException: OGR failure. I get this on the following statement. def getDistanceBetweenTwoLocations(source,dest): try: employeeLocation = source.transform(32148, clone=True) <---Error employerLocation = dest.transform(32148, clone=True) distance = Distance(m=employerLocation.distance(employeeLocation)) dis = round(distance.mi, 2) # Convert to miles return dis except (Exception,): print("Unexpected error:", ) Any suggestions on what I might be doing wrong ? -
Django MismatchingStateError CSRF Warning
I am implementing an OAuth Authorization to connect my app to Microsoft Graph API, during callback to my URL http://localhost:8000/callback, the following error happens: MismatchingStateError at /ms/callback (mismatching_state) CSRF Warning! State not equal in request and response. Request Method: GET Request URL: http://localhost:8000/callback?code=0.AS0Al1INNTARS0G_Qyd..... Django Version: 3.2.5 Exception Type: MismatchingStateError Exception Value: (mismatching_state) CSRF Warning! State not equal in request and response. views.py: def get_token_from_code(callback_url, expected_state): aad_auth = OAuth2Session(settings['app_id'], state=expected_state, scope=settings['scopes'], redirect_uri=settings['redirect']) token = aad_auth.fetch_token(token_url, client_secret = settings['app_secret'], authorization_response=callback_url) return token def callback(request): expected_state = request.session.pop('auth_state', '') token = get_token_from_code(request.get_full_path(), expected_state) user = get_user(token) store_token(request, token) store_user(request, user) return HttpResponse("OK") urls.py: urlpatterns = [ path('signin', views.sign_in, name='signin'), path('signout', views.sign_out, name='signout'), path('callback', views.callback, name='callback'), path('callback/', views.callback, name='callback'), ] -
What is the best approach to bind multiple models to one ManyToMany field in Django?
I'm building a dashboard app that I would like the user to be able to customize. One of these customizable options would be the ability to choose different types of graphs to display data. My research into the best way to do this would be to use a ManyToMany field within my dashboard model; however, ManyToMany fields only allow 1 model--not multiple according to the docs: A many-to-many relationship. Requires a positional argument: the class to which the model is related, which works exactly the same as it does for ForeignKey, including recursive and lazy relationships. More research brought me to this SO post which recommended to create an intermediary 'ABCDRel' model that has foreign keys to each of the other models and emulate the behavior I'm looking for. The problem with that is I get this: as compared to what I'm looking for in this: I use the admin page here to give a clearer picture of what I'm looking for. Here's the intermediary I made according to the SO post above: class GraphRelations(models.Model): heatmap = models.ForeignKey(Heatmap, on_delete=models.CASCADE, related_name='m2m') bar = models.ForeignKey(Bar, on_delete=models.CASCADE, related_name='m2m') And the ManyToMany field I have in my dashboard model: graphs = models.ManyToManyField(GraphRelations) -
Sending password reset email with django
I have a small blog that developing. I want to send an email containing a link to a password reset page after a user signs up using only email. def email_signUp(request): if request.method == 'POST': if 'email_subscription' in request.POST: form = EmailForm(request.POST) if form.is_valid(): fields = ["username", "email", 'password1', 'password2', ] username = form.cleaned_data['email'].split('@')[0] email = form.cleaned_data['email'] password1 = passgen() password2 = password1 User.objects.create_user(username=username, email=email, password=password1) How can I send the email? I already have password reset page accessible at 'password_reset/' Am using if DEBUG: EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' -
Submit File to Django API from Angular
I am using Django as my API and trying to upload Pdf file from Angular I have used the HttpModule to post the file with the name, company, year and document I have tested the post url on Postman and it works link to the postman API showing the post request was successful When I click the upload there is no activity on the Network tab and no output on console This is my Django API url.py router = routers.DefaultRouter() router.register(r'reports', views.ReportViewSet) urlpatterns = [ path('', include(router.urls)), url(r'^upload/$', TestUploadView.as_view(), name='upload'), #path('api-auth/', include('rest_framework.urls', namespace='rest_framework')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) serializers.py from .models import Report class ReportSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Report fields = ('name', 'company', 'year', 'document') Angular code in app.component.ts export class AppComponent { title = 'angular-frontend' name!: string; company!: string; year!: string; document!: File; constructor(private http: HttpClient) { } onNameChanged(event: any) { this.name = event.target.value; } onCompanyChanged(event: any) { this.company = event.target.value } onYearChanged(event: any) { this.year = event.target.value } onDocumentChanged(event: any) { this.document = event.target.files[0]; } Upload() { const uploadData: FormData = new FormData(); uploadData.append('name', this.name); uploadData.append('company', this.company); uploadData.append('year', this.year); uploadData.append('document', this.document); this.http.post('http://127.0.0.1:8000/api/reports/', uploadData).subscribe( data => console.log(data), error => console.log(error) ) } } app.component.html <label> Name: <input type="text" (change)="onNameChanged($event)" … -
Why explicitly specified read only field is also writable in django serializer?
class ProductSerializer(serializers.ModelSerializer): category_info = CategorySerializer(source="category", read_only=True) The category_info field is still writable. I tried write_only=False and required=False also but nothing works. Can someone tell me how to resolve this? -
wsgi:error ModuleNotFoundError: No module named 'django_project.settings'
I'm trying to setup my django app on a linode server using apache. I followed this tutorial: https://www.youtube.com/watch?v=Sa_kQheCnds I'm really struggling with this problem where apache gives me the error: [wsgi:error] ModuleNotFoundError: No module named 'django_project.settings' I know it's finding the wsgi.py file because if I change it to this for example: os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_name.settings") the error message changes to match. I found this post that seemed to have the same problem: ImportError: No module named mysite.settings (Django) but the solution didn't work for me. I tried adding sys.path.append("/home/daniel/django_project") and sys.path.append("/home/daniel/django_project/django_project") and sys.path.append("/home/daniel/django_project/django_project/settings") each individually, all to no avail. My file tree is /home/daniel/django_project/django_project/settings/production.py. But even if move the production.py file back to its original position and name I still get the same error. It just can't find my settings file and I don't know why. Please help! Here's the django_project.conf file <VirtualHost *:80> DocumentRoot /var/www/html <Directory /home/daniel/django_project> Options Indexes FollowSymLinks DirectoryIndex index.html index.php AllowOverride All Order Allow,Deny Allow from all Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <Directory /home/daniel/django_project/django_project> <Files wsgi.py> Require all granted </Files> </Directory> WSGIscriptAlias / /home/daniel/django_project/django_project/wsgi.py WSGIDaemonProcess django_app python-path=/home/daniel/django_project/django_project python-home=/home/daniel/env WSGIProcessGroup django_app </VirtualHost> -
How to display menu items for restaurant based on menu type selected
Please forgive my ignorance but very new to this and still learning! I am creating a webapp for a restaurant that will include all menus for customers to view. I have created a database model in models.py from django.db import models """ A Menu represents a collection of categories of food items. For example, a restaurant may have a Lunch menu, and a Dinner menu. """ class Menu(models.Model): name = models.CharField(max_length=246, unique=True,) slug = models.SlugField(max_length=24, unique=True, help_text='The slug is the URL friendly version of the menu name, so that this can be accessed at a URL like mysite.com/menus/dinner/.') additional_text = models.CharField(max_length=128, null=True, blank=True, help_text='Any additional text that the menu might need, i.e. Served between 11:00am and 4:00pm.') order = models.PositiveSmallIntegerField(default=0, help_text='The order of the menu determines where this menu appears alongside other menus.') class Meta: verbose_name = 'menu name' def __str__(self): return self.name """ A Menu Category represents a grouping of items within a specific Menu. An example of a Menu Category would be Appetizers, or Pasta. """ class MenuCategory(models.Model): menu = models.ForeignKey(Menu, null=True, help_text='The menus that this category belongs to, i.e. \'Lunch\'.', on_delete=models.SET_NULL) name = models.CharField(max_length=32, verbose_name='menu category name') additional_text = models.CharField(max_length=128, null=True, blank=True, help_text='The additional text is any … -
python manage.py collectstatic --noinput error deploying django app
I am trying to deploy a django app on heroku. The app was working before made some few adjustments and has refused to work. It keeps throwing this error. I have tried changing the path and all of the solutions I saw earlier here. None seems to be working. Here is the error python manage.py collectstatic --noinput Traceback (most recent call last): File "manage.py", line 22, in <module> main() File "manage.py", line 18, in main execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/base.py", line 330, in run_from_argv self.execute(*args, **cmd_options) File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/base.py", line 371, in execute output = self.handle(*args, **options) File "/app/.heroku/python/lib/python3.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 194, in handle collected = self.collect() File "/app/.heroku/python/lib/python3.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 109, in collect for path, storage in finder.list(self.ignore_patterns): File "/app/.heroku/python/lib/python3.7/site-packages/django/contrib/staticfiles/finders.py", line 130, in list for path in utils.get_files(storage, ignore_patterns): File "/app/.heroku/python/lib/python3.7/site-packages/django/contrib/staticfiles/utils.py", line 23, in get_files directories, files = storage.listdir(location) File "/app/.heroku/python/lib/python3.7/site-packages/django/core/files/storage.py", line 316, in listdir for entry in os.scandir(path): FileNotFoundError: [Errno 2] No such file or directory: '/tmp/build_b09672bc/pilgrimage/static' ! Error while running '$ python manage.py collectstatic --noinput'. See traceback above for details. You may need to update application code to resolve this error. Or, you can disable collectstatic for this … -
Django-Share logins between different subdomains
I have 2 inter-related pages say, a.abc.com and b.abc.com . I am using SAML SSO for authentication. When the user hits either of the URLs above, I authenticate the user based on his email. The source IdP(onelogin) is the same for both the URLs. . We can suppose that 'a' and 'b' are different branches within the same organization. We show the data based on the context - 'a' or 'b'. Some users have access to both the branches in the organization. That's why I want to give the user a capability to switch the context b/w 'a' and 'b', without the hassle of opening two different tabs. My goal - If the user logs in using a.abc.com, I take him to the appropriate page, show info of 'a'. I also give him an option to switch to the context of 'b'. If the user switches the context to 'b', I want the URL to change to b.abc.com and show the page with the 'b' context The functionality would be the same vice versa, when the user logs in using b.abc.com I am using Django-python framework. How do I achieve this in the most optimal way? What I already tried …