Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Set primary key in Django
The title is not entirely accurate, but I do not know how to explain, so I took a screenshot of where my problem is, and I will try to explain what I am trying to achieve. I have a vehicle model, and when I create a new vehicle object, the name of vehicles just says Vehicle object (1) How can I change my model, or serializer (or something else) so that will show some unique value of the object. Here is my model: class Vehicle(models.Model): make = models.CharField(max_length=100, blank=True) model = models.CharField(max_length=300, blank=True) license_plate = models.CharField(max_length=7, blank=True) vehicle_type = models.CharField(max_length=20, blank=True) seats = models.IntegerField(default=4, validators=[ MaxValueValidator(70), MinValueValidator(4)], ) year = models.IntegerField(_('year'), default=datetime.today().year - 10, validators=[ MinValueValidator(1975), max_value_current_year]) inspected = models.BooleanField(default=True) # fuel_type # fuel_price created_at = models.DateTimeField(auto_now_add=True) -
How to Assign New users to Old Users As Upline Payment in django based on Category
Am building a django project and i want Newly Authenticated User to be Attached to Old Authenticated User as Upline for payment purposes(i sure know how to handle the payment case). This Attachment or Assign of this New User to Old User should be based on the Request of the Old User and the willingness of the New Users. There is a payment category for Users of the App in a range of $50, $100, $150, $200. Lets take for example- the old User Request For a payment of $50 and the new user select a category of payment of $50. Then the new user which is assigned to the old user will be automatically Assigned to pay the new User the amount Category Requested by the old User and agreed upon by the New Users. After the Request from the old User and Request from the New User then i will want my app to automatically assign the old user to the new user. Note. I will determine the other conditions that will enable the old user elligible to make such requests. Lets take a look at my Code. Payment Category Class PayCategory(models.Model): Amount = models.Charfield(max_length=6) My Manager which … -
Pass parameter through django-allauth url
Before authenticating an user with Google in my page, I have an input that users can fill in with a special name, let's call this name variable nombrelink. When the user fills in the input and clicks submit, I send a fetch post request to the server to check wether that name is already taken or not. The problem is: when the person completes that input and THEN tries to sign up with google, I can't find a way to insert nombrelink into the database of the recently google created user. This is what happens on the server, to check wether the input name (nombrelink) is already taken or not. def landing(request): if request.method == "POST": content = json.loads(request.body) creator = Creador.objects.filter(url_name=content['nombrelink']).first() if not creator: content.update({"nadie": "nadie"}) return JsonResponse(content) else: return JsonResponse(content) return render(request, 'app1/landing.html') So in summary what the code should be doing is: The user fills in the input with a name that gets stored in nombrelink If nombrelink is not taken, then the user can register via google allauth nombrelink gets added to my google created user model I'm failing to implement point 3 -
Django Bootstrap - How to parse a variable from a local JSON file and display it in a .html template?
I'm new to JS and would like to display in my html file a variable to be parsed from a local JSON file ? I'm running that in Django with bootstrap. myfile.json contains: [{"myvar":"1500000"}] my html template contains: ... <div class="col-9"> <h3 class="f-w-300 d-flex align-items-center m-b-0"><i class="feather icon-arrow-up text-c-green f-30 m-r-10"></i><span id="output_1"></span></h3> </div> ... ... <!-- Specific Page JS goes HERE --> {% block javascripts %} {% load static %} <script src="{% static 'dashboard_data.json' %}"> var my_kpi = fetch("/static/dashboard_data.json") .then(response => response.json()) .then(data => { console.log(data.myvar) document.querySelector("output_1").innerText = data.myvar }); document.getElementById('output_1').innerHTML = my_kpi </script> {% endblock javascripts %} I'm not sure what I'm doing wrong. From the development tool when debugging in the browser, I can see that the JSON file appears in the sources, but the myvar value does not show in the console nor in the html page. It looks like nothing is being parsed at all inside my_kpi. Many thanks for your help. -
How do I update a CustomUser value via UpdateView using a hidden logic
I've spent several hours on this and I'm not able to see any signs as to why the change on the flag is not getting through. Please note the change form already works for all exposed fields, i.e. the user can go in and change the name or country already and it will get saved after clicking on update profile. What I'm now trying to do is to also change the confirmed_email flag to True (but without telling or letting the user see it) whenever the client makes an update to the form. To do this I check if the user was logged in using Linkedin (or any Social account for that matter) via something along the lines of ""if user.social_auth.exists()"". That said, it's not that i can't fulfill this function, it's that even when i use a silly condition that i know it's true the field "email_confirmed" will still NOT change to True in the back-end. Thanks so much in advance. I appreciate your time. PS. I'm a noob with Django but loving it. Models.py class CustomUser(AbstractUser): id = models.BigAutoField(primary_key=True) email = models.EmailField(unique=True) email_confirmed = models.BooleanField(default=False) country = models.CharField(max_length=30,choices=COUNTRY, null=True, blank=False) first_name = models.CharField(max_length=50, null=False, blank=False, default="") last_name = … -
UNIQUE constraint failed: main_user.username
Help with this error and I'm trying that my phone be my username but i dont know exactly why but when i create a new object for my model user, the register isn't being save in the same row models.py from django.db import models from django.contrib.auth.models import AbstractUser class User(AbstractUser): address= models.CharField( max_length=50 ) gender = models.CharField( max_length=30 ) celular = models.CharField( unique=True,max_length=16 ) genero = models.CharField( choices=(('M', 'Mujer'), ('H', 'Hombre')), max_length=16, blank=True ) fecha_nacimiento = models.DateField( null=True ) forms.py class UserForm(ModelForm): class Meta(): model = User fields=['celular'] views.py def user_register(request): if request.method == 'POST': form = UserForm(request.POST) if form.is_valid(): x= form.cleaned_data['celular'] # User.objects.create(username=x) print(x) form.save() return redirect('index',) else: form = UserForm() return render(request, 'useregister.html', {'form': form}) An example for celular= username on my database Sqlite3 1 name last name celular username 123 2 name last name celular username 123 -
Django form dropdown field shows data owned by other users
I have trouble querying only user owned items from CreateView and Form: # views.py class ExpenseCreateView(LoginRequiredMixin, CreateView): model = Expense form_class = ExpenseCreateForm template_name = "expenses/expense_form.html" success_url = reverse_lazy("expense-list") def form_valid(self, form): form.instance.owner = self.request.user return super(ExpenseCreateView, self).form_valid(form) # forms.py class ExpenseCreateForm(forms.ModelForm): class Meta: model = Expense exclude = ("owner", ) widgets = {"date": DateInput(), "time": TimeInput()} # models.py class Expense(models.Model): date = models.DateField(db_index=True) time = models.TimeField(null=True, blank=True) amount = models.DecimalField(max_digits=10, decimal_places=2, help_text="Amount of € spent.") location = models.ForeignKey("Location", on_delete=models.SET_NULL, null=True) document = models.FileField( upload_to=UploadToPathAndRename("documents/"), blank=True, null=True ) image = models.ImageField( upload_to=UploadToPathAndRename("images/"), blank=True, null=True ) payment = models.ForeignKey("Payment", on_delete=models.SET_NULL, db_index=True, null=True) comment = models.TextField(null=True, blank=True, help_text="Additional notes...") owner = models.ForeignKey(User, on_delete=models.CASCADE) class Payment(models.Model): title = models.CharField(max_length=100) comment = models.TextField(blank=True, null=True) owner = models.ForeignKey(User, on_delete=models.CASCADE) The form works, but every user can see Location and Payment of other users. Which is the right spot and way to add validation/check to only return Location which is owned by the user issuing request? -
Dokku: setuidgid: fatal: unable to run gunicorn: file does not exist
I am trying to run my application in Dokku I get this error: 5b188e740fcae5a5080e2ac498e6b93a593ae107e656c53e5df1d8c8e13948c8 remote: ! App container failed to start!! =====> lala web container output: setuidgid: fatal: unable to run gunicorn: file does not exist setuidgid: fatal: unable to run gunicorn: file does not exist setuidgid: fatal: unable to run gunicorn: file does not exist setuidgid: fatal: unable to run gunicorn: file does not exist setuidgid: fatal: unable to run gunicorn: file does not exist setuidgid: fatal: unable to run gunicorn: file does not exist setuidgid: fatal: unable to run gunicorn: file does not exist =====> end lala web container output remote: 2020/12/17 23:22:13 exit status 1 remote: 2020/12/17 23:22:13 exit status 1 remote: 2020/12/17 23:22:13 exit status 1 To coffee-and-sugar.club:lala ! [remote rejected] main -> master (pre-receive hook declined) -
check_password not working for django custom user model
I have created a custom backend which accepts email/password combo only. The backend with the authentication function is as so: class EmailOnlyBackend(ModelBackend): def authenticate(self, request, email, password): try: user = get_user_model().objects.get(email=email, is_email=True) print(user) if user.check_password(password): return user except get_user_model().DoesNotExist: return None def get_user(self, user_id): try: return get_user_model().objects.get(pk=user_id) except get_user_model().DoesNotExist: return None The account manager model and the user model are: class MyAccountManager(BaseUserManager): def create_user(self, email, password=None, username="", is_email=None): if not email: raise ValueError("Missing email address") try: get_user_model().objects.get(email=email, is_email=True) raise ValueError("User with this email address already exists") except get_user_model().DoesNotExist: pass user = self.model(email=self.normalize_email(email)) user.set_password(password) if is_email: user.is_email = True user.save(using=self._db) return user class EmailOnlyUser(AbstractBaseUser): email = models.EmailField(verbose_name='email', max_length=60, unique=False) username = models.CharField(max_length=30, unique=False) date_joined = models.DateTimeField(verbose_name='date_joined', auto_now_add=True) last_login = models.DateTimeField(verbose_name='last_login', auto_now=True) is_email = models.BooleanField(default=False) is_admin = models.BooleanField(default=False) is_active = models.BooleanField(default=False) is_staff = models.BooleanField(default=False) is_superuser = models.BooleanField(default=False) objects = MyAccountManager() USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] def __str__(self): return self.email I can't give much info as I don't know what's causing it, the emails and passwords are passed correctly as strings down to the set_password and check_password functions and the user is then added to the db with the hashed password, but when logging in the check_password in authenticate never returns true. -
get field name from one app to another app in django
We have defined two apps: Manin_matrix and SW_matrix. We want the field name (project_name) present in class GENERAL_t of modle.py file inside Main_matrix app to be inside the models.py file of SW_matrix app. Basically project_name_work field in class EDVT of SW_matrix models.py should be same as project_name of Main_matrix app. We want this so that in database for EDVT table we will get the same project id along with project name. Main_matrix/models.py class GENERAL_t(models.Model): project_name = models.CharField(blank=True, null=True, max_length=40, verbose_name = 'Project_Name') platform = models.CharField(blank=True, null=True, max_length=40, verbose_name = 'Platform SW') SW_matrix/models.py class EDVT(models.Model): project_rel=models.ForeignKey(GENERAL_t,null=True,on_delete=models.SET_NULL,verbose_name="Choose Project") project_name_work = models.ForeignKey(GENERAL_t.project_name, null=True, verbose_name = 'Project_Name') -
Django shared model instance with per user overrides
I have a Django model that I want to centrally manage for my users. However, I also want users to be able to modify some fields for themselves, while allowing the central control to update the referenced model and have those updates appear for users (unless they have overriden this field). For this example, let's make it a store page, where users have their own whitelabeled pages. Items are created centrally, but each individual user can (optionally) edit the description and price for their own store. Centrally managed item: class StoreItem(models.Model): unit_id = models.CharField(max_length=200, unique=True) name = models.CharField(max_length=200) description = models.TextField() price = models.DecimalField(max_digits=5, decimal_places=2) Item that a user has overriden: class UserStoreItem(models.model): user = models.ForeignKey(User, on_delete=models.CASCADE) item = models.ForeignKey(StoreItem, on_delete=models.CASCADE) # I'd like these fields to be inherited from the item ForeignKey if not set description = models.TextField(blank=True, null=True) price = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True) Is there a good way to do what I'm looking for? I've thought about just copying StoreItem for each user however that would lose the ability to be updated centrally. Bonus points if I'm able to have UserStoreItem inherit StoreItem's fields without having to define them twice. -
Ingredient - Stock - Order Database Design Django
I am designing an EPOS and I have some doubts regarding the stock - ingredient - order database schema that I came up with. Essentially, I am trying to find any flaws in the design so any feedback would be appreciated. Some of the requirements are: When an ingredient is received from a supplier, add it to the total count in stock Track quantity of each ingredient in stock When an order is placed, remove the quantity of the ingredient from stock Each product could have a different amount of an ingredient Calculate profit for each order based on spent ingredients for each product in the order My current DB design: Ingredient represents the concept of an Item that could be ordered from a supplier. It would be a single Model object in the DataBase. StockIngredient represents the total amount of the same Ingredient in the database, so each time there is an ingredient received from a supplier, or used for a product the total_weight would be changed, therefore, StockIngredient would also be a single object Model. IngredientForProduct would represent the quantity of the StockIngredient needed for each product. Product it's pretty self-explanatory, it has different IngredientForProduct -
django-select2 class-based or function based views
I'm thinking of using django-select2 project on my forms, but I'm mostly concerned about views do they have to be class-based views or I can use regular function views ? In the documentation they only mention class-based views but didn't say a word about function based views (like in snippet below) so I don't know if it will work with my regular function views? Thanks in advance. https://django-select2.readthedocs.io/en/latest/ A simple class based view will do, to render your form: # views.py from django.views import generic from . import forms, models class BookCreateView(generic.CreateView): model = models.Book form_class = forms.BookForm success_url = "/" -
Clerk matching query does not exist
I have a Clerk Model with the following field: status = models.CharField(max_length=50, null=True, choices=STATUS, default=STATUS[0][0]) And in login_view I want to check my user status. So I do: def login_view(request): if request.method == 'POST': username = request.POST.get('username') password = request.POST.get('password') user = authenticate(request, username=username, password=password) user_status = Clerk.objects.get(user__username=user.username) print(user_status) Here I get this error: Clerk matching query does not exist. -
Django Puput (Wagtail based blog) can't config disqus for comments
requirements: Python 3.8.6 Django 3.0.7 Puput 1.1.1 Wagtail 2.9 Over a Django project I installed Puput following instructions for a Standalone blog app and everything works fine until I want to activate the blog comments section with Disqus. The Puput comments documentation is very light so probably everything is straight forward but in my case something is missing or do not worked as intended. I did created a Disqus account to have the Disqus shortname and I registered my site on Disqus API Resurses for the Disqus api secret. Both of them requested on the admin site of the blog. On this point I have an Exception error/message: To use comments you need to specify PUPUT_COMMENTS_PROVIDER in settings. Request Method: GET Request URL: http://localhost/blog/why-you-should-include-webassembly-your-knowledge-portfolio-reasons-pragmatic-programmers/ Django Version: 3.0.7 Exception Type: Exception Exception Value: To use comments you need to specify PUPUT_COMMENTS_PROVIDER in settings. Exception Location: /home/helly/dev/.venvs/wanttolearn/lib/python3.8/site-packages/puput/templatetags/puput_tags.py in show_comments, line 102 Python Executable: /home/helly/dev/.venvs/wanttolearn/bin/python3 Python Version: 3.8.6 I tried to add a variable in my project settings.py PUPUT_COMMENTS_PROVIDER = 'Disqus' and this time I have a ValueError error not enough values to unpack (expected 2, got 1) Request Method: GET Request URL: http://localhost/blog/why-you-should-include-webassembly-your-knowledge-portfolio-reasons-pragmatic-programmers/ Django Version: 3.0.7 Exception Type: ValueError Exception Value: not … -
Django send_mail() only spits two arguments... I want three
I cannot seem to find an answer in Stackoverflow so I decided to post the issue. I am using django send_mail() and I include the NAME, EMAIL and MESSAGE but for some strange reason only NAME and EMAIL get sent. Basically, the third argument gets ignored and I cannot figure out why. CLARIFICATION: the email sends and works flawlessly, but I cannot get Django to spit the third argument for message. This is my code: def index(request): if request.method == "POST": message_name = request.POST['message-name'] message_email = request.POST['message-email'] message = request.POST['message'] send_mail( 'Email from ' + message_name, message, message_email, ['myemail@gmail.com'], ) return HttpResponseRedirect(reverse("index")) return render(request, 'base/index.html', {'message_name': message_name}) else: return render(request, 'base/index.html', {}) -
Browser back button scenario in Django Application
Please help me on the below scenario: i have created a django form,after filling the form there is chance the user may press the back button,at this point ,it should pop-up a message saying save or cancel the form.when i say "save" the form should submit and when i say cancel it should go to the previous page. after research,i understand javascript helps on this requirement,but i didnt find the related one to guide me. wat i need to add in my view and in my html code. how can i achieve ,iam a beginner in coding and also asking questions in stackoverflow. views.py def create(request): context = {} testlogFormset = modelformset_factory(testlogs, form=testlogForm) form = shoporderForm(request.POST or None) formset = testlogFormset(request.POST or None, queryset= testlogs.objects.none(), prefix='testlogs') # if request.method == "POST": if form.is_valid() and formset.is_valid(): with transaction.atomic(): shoporder_inst = form.save(commit=False) shoporder_inst.save() for mark in formset: data = mark.save(commit=False) data.shoporderno = shoporder_inst data.save() return redirect("/create") context['formset'] = formset context['form'] = form return render(request, 'prod_orders/create.html', context) -
Updating required ImageField from URLField (as option)
Given the setup below, is it possible to offer an optional, "virtual" URLField, that will set a required ImageField if the latter is not supplied? class ReleaseImage(models.Model): release = models.ForeignKey(Release, on_delete=models.CASCADE) image = models.ImageField(upload_to='images/releases') class ReleaseImageForm(forms.ModelForm): image_from_url = forms.URLField(required=False) class Meta: fields = '__all__' model = ReleaseImage class ReleaseImageAdmin(admin.ModelAdmin): form = ReleaseImageForm I have attempted some different methods, without success, e.g. overriding clean on the ModelForm as below, but the form is not validated (complaining that image is required). def clean(self): super().clean() # ... download image from url ... image = SimpleUploadedFile(name="foo.jpg", content=bytes_downloaded_from_url) self.cleaned_data["image"] = image # self.instance.image = image # also attempted ... return self.cleaned_data What would be the best way of doing this? I'm getting somewhat confused whether this should live in save, clean, or clean_FOO, in the model, the modeladmin or the modelform -- or a combination of this somehow`? -
ajax call to filter select field in django
I have a form with two fields related to each other and I want the rooms filtered based on the class in the front form this is my code models.py class Class(models.Model): class_name = models.CharField(max_length=100) def __str__(self): return self.class_name class Room(models.Model): room_name = models.CharField(max_length=100) class = models.ForeignKey(Class,related_name='class',on_delete=models.SET_NULL, null=True) def __str__(self): return self.room_name views.py class CustomFormView(LoginMixin, TemplateView): template_name = 'form.html' def get(self, request, *args, **kwargs): context = self.get_context_data(**kwargs) context['class'] = Class.objects.values('pk','class_name') context['rooms'] = Room.objects.all() return self.render_to_response(context) def get_related_rooms(request): class_id = request.GET.get('class_id') rooms = Room.objects.filter(class_id=class_id) return render(request, 'form.html', {'rooms': rooms}) form.html <form id="custom_form" data-rooms-url="{% url 'app:get_related_rooms' %}"> Class Name: <select type="text" class="form-control"id="class_name" name="class_name"> {% for c in class %} <option value="{{ c.pk }}">{{ c.class_name }}</option> {% endfor %} </select> Room Name: </label> <select type="text" class="form-control" id="room_name" name="room_name"> {% for r in rooms %} <option value="{{ r.pk }}">{{ r.room_name }}</option> {% endfor %} </select> </form> //here is the ajax call to get the rooms <script> document.getElementById("#class_name").change(function () { var url = $("#custom_form").attr("data-rooms-url"); var classId = $(this).val(); $.ajax({ url: url , method: 'GET', data: { 'class_id': classId }, success: function (data) { $("#room_name").html(data); } }) }); </script> I want to make this: When I choose the class in the first select I want to … -
How to install mod_wsgi on aws linux 2
I am trying to install mod-wsgi on Linux 2. But I am getting this error error: command 'gcc' failed with exit status 1 ERROR: Command errored out with exit status 1: /home/ec2-user/venv/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-jzcb7l6h/mod-wsgi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-jzcb7l6h/mod-wsgi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-zrs06wit/install-record.txt --single-version-externally-managed --compile --install-headers /home/ec2-user/venv/include/site/python3.7/mod-wsgi Check the logs for full command output. This is what I have tried yum install gcc openssl-devel bzip2-devel libffi-devel zlib-devel cd /usr/src sudo wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz sudo tar zxvf Python-3.7.9.tgz ./configure --enable-shared ./configure --enable-optimizations #sudo make sudo make altinstall python3.7 --version cd ~ python3.7 -m venv venv source venv/bin/activate sudo yum update httpd sudo yum install httpd sudo yum install httpd-devel pip install mod-wsgi -
Django - Filter based on href?
Is there a way to filter based on the href contents? I have a .html page that has a link <td><a href="{% url 'ipDATA' %}">{{item.IP_Address}}</td> I have a function like this: def ipDATA(request, Host=IPs.IP_Address): items = NessusReports.objects.filter() context = { 'items': items, } return render(request, 'nessusdata.html', context) Right now, it returns the entire table, I want to filter based on the href. -
make staff user not edit superuser's username
In my django-admin panel i'm trying to make that the staff-user can make new user-accounts where it needs to add a username but the staff-user shouldn't be abel to edit the superuser's username. Right now this doesn't happens with the code. admin.py from typing import Set from django.contrib import admin from django.contrib.auth.models import User from django.contrib.auth.admin import UserAdmin # Unregister the provided model admin admin.site.unregister(User) # Register out own model admin @admin.register(User) class CustomUserAdmin(UserAdmin): def get_form(self, request, obj=None, **kwargs): form = super().get_form(request, obj, **kwargs) is_superuser = request.user.is_superuser is_staff = request.user.is_staff disabled_fields = set() # type: Set[str] if not is_superuser: disabled_fields |= { 'is_superuser', 'user_permissions', 'is_staff', 'date_joined', } # Prevent non-superusers from editing their own permissions if ( not is_superuser and obj is not None and obj == request.user ): disabled_fields |= { 'is_staff', 'is_superuser', 'groups', 'user_permissions', 'username', } for f in disabled_fields: if f in form.base_fields: form.base_fields[f].disabled = True return form # No delete button def has_delete_permission(self, request, obj=None): return False -
How do I fix these errors when installing a plugin for python bot?
I'm attempting to use Bots Open Source EDI Translator on my Mac, and successfully ran the webserver and monitor according to their guide*, but I receive this error whenever I try to read a plugin. Server Error (500) Traceback (most recent call last): File "/Users/myusername/Documents/Work/Python/bots_edi/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/Users/myusername/Documents/Work/Python/bots_edi/venv/lib/python2.7/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view return view_func(request, *args, **kwargs) File "/Users/myusername/Documents/Work/Python/bots_edi/bots-3.2.0/bots/views.py", line 447, in plugin notification = -(u'Error reading plugin:"%s".')%unicode(msg) TypeError: bad operand type for unary -: 'unicode' *I did make some adjustments when following the installation guide. I created my virtual environment to operate with Python2.7, and when I tried to run the permissions line: sudo chown -R myusername /usr/lib/python2.7/site-packages/bots, it could not find the file. I'm assuming that's because I'm running a virtual environment, so I skipped it. Perhaps that's what's causing the issues now? If so, how do I manage my virtual environment with the sudo commands? Should I somehow be installing the dependencies (cherrypy, django, genshi) inside my virtual environment? -
Best way to serve npm packages with django?
I am using django as a backend with a few js packages installed with npm. I am currently accessing the packages by allowing django to serve /node_modules by adding it to the STATICFILES_DIRS. This has been working, but I have to go in the pacakge and find the js file I want to point to and then load it using a <script src="{% static .... This is a bit tedious and seems a bit "hacky." I also cannot figure out how to use imports/requires inside my js files. Is there a way to use imports or am I stuck loading everyting via script tags? I assume this is because django doesn't know how to server the npm packages appropriately? I've read a bit into webpack and I'm still unsure if webpack is a solution to my problem. Any advice? -
Running both Django and PHP on IIS (Internet Information Services) server
I have a previous application done with PHP and I have created another django project. I'm trying to run them both on IIS server as the existing PHP project is served through IIS. When I'm running PHP and Django separately, its working fine but if I configure IIS for running django and then go to the url of the php file (localhost/test.php), its testing for the route in urls.py and returning the possible urls like /home, /about. I need to display django views while visiting URLs in the urls.py and run php file while visiting the php url. Is there any way that I can do this? Any answer is appreciable. Thanks in Advance :)