Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django: How to keep db structure without data after running tests?
I want to use the --keepdb option that allow to keep the database after running tests, because in my case, the creation of the dabatase takes a while (but running tests is actualy fast) However, I would like to keep the database structure only, not the data. Each time a run tests, I need an empty database. I know I could use tearDown method to delete each object created, but it is a tedious and error-prone way to do. I just need to find a way to tell Django to flush the whole dabatase (not destroy it) at the end of the unit tests. Is there an easy way to do it? Thanks! -
How does django-contrib-requestprovider work?
I found this middleware (django-contrib-requestprovider) in comments on SO, it was suggested to solve the problem of getting current request outside of views. The source code is very simple, but I can't understand, how the process_request function works (does it invokes every time, when request comes?), and how this middleware will work when django is run multithreaded. -
django chartit accumulate field values
I have a model like this class Match(models.Model): defender = models.ForeignKey(Player,...) attacker = models.ForeignKey(Player,...) time = models.DateTimeField(...) ratingChange = models.IntegerField(...) and I would like to make a graph which shows the absolute rating for a certain player with time. I understand that I get the corresponding matches by 'source': Match.objects.filter(Q(defender__name='myname) | Q(attacker__name='myname')) which works fine. However, the variable ratingChange just gives the change of rating during that match. I'd need to accumulate all the rating changes before passing them to the terms key of DataPool, something like np.cumsum('ratingChange'). Is that even possible with chartit? Here is the full DataPool object: matchdata = \ DataPool( series= [{'options': { 'source': Match.objects.filter(Q(defender__name='myname) | Q(attacker__name='myname'))}, 'terms': { 'Date':'time', 'Points':'ratingChange' } } ]) -
Django SplitDateTimeWidget
I'm trying to get the widget working on my form but for whatever reason, it ends up looking like a charfield. I've searched for related material, but I don't find anything current that says my code is wrong. What am I missing here? models.py class ServiceReportModel(models.Model): report_number = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) site = models.ForeignKey(customers_models.SiteModel, on_delete=models.PROTECT) request_number = models.ForeignKey(ServiceRequestModel, on_delete=models.PROTECT, null=True, blank=True, related_name='s_report_number' ) reported_by = models.ForeignKey(main_models.MyUser, related_name='reports') reported_date = models.DateTimeField(auto_now_add=True) updated_by = models.ForeignKey(main_models.MyUser, blank=True, null=True, related_name='+') updated_date = models.DateTimeField(auto_now=True) equipment = models.ForeignKey(customers_models.EquipmentModel, on_delete=models.PROTECT) report_reason = models.CharField(max_length=255, null=True) time_in = models.DateTimeField(blank=True, null=True) time_out = models.DateTimeField(blank=True, null=True) actions_taken = models.TextField(null=False, blank=False) recommendations = models.TextField(null=True, blank=True) def get_absolute_url(self): return reverse('service-report', kwargs={'pk': self.pk}) def __str__(self): return '%s - %s, %s' % (self.site.company, self.reported_date.strftime('%d %B %Y'), self.equipment.name) class Meta: ordering = ['reported_date'] verbose_name = 'Service Report' verbose_name_plural = 'Service Reports' forms.py class ServiceReportCreateForm(forms.ModelForm): time_in = forms.SplitDateTimeField(widget=SplitDateTimeWidget( date_format='%d/%m/%Y', time_format='%H:%M.%S')) time_out = forms.SplitDateTimeField(widget=SplitDateTimeWidget( date_format='%d/%m/%Y', time_format='%H:%M.%S')) class Meta: model = ServiceReportModel fields = [ 'site', 'request_number', 'reported_by', 'equipment', 'report_reason', 'actions_taken', ] widgets = { 'report_reason': forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Enter Reason for Service Report'}), 'actions_taken': forms.Textarea(attrs={ 'class': 'form-control', 'placeholder': 'To the best of your abilities, list all actions taken during service. Please include' + 'dates, times, and equipment … -
How to solve strange URL ERROR in Django?
I have form like this.. {% extends 'DATAPLO/base.html' %} {% load staticfiles %} {% block content %} <form action="/cholera/SeqData/result_page/" method="post"> <div style=" color: #1f5a09; margin: auto; margin-top: 10px; height: 15%; border: 1px solid green; box-sizing: border-box;background: #9fc36a; width: 100%"> <div style= "margin-left: 15px;"> <p style="color: #000000 "; > <b>Enter year range to explore seqence data country wise</b> </p> </div> {% csrf_token %} <div style= "margin-left: 5px; margin-right: 50px;margin-top: 2px"> <b>Start year:</b> {{ form.start_year }} </div> <div style= "margin-left: 13px; margin-right: 54px;margin-top: 2px"> <b> End year:</b> {{form.end_year }} </div> <div style= "margin-left: 17px; margin-right: 50px;margin-top: 2px"> <b>Country:</b> {{form.country }} </div> <div style= "margin-left: 75.5px; margin-right: 50px;margin-top: 5px"> <input type="submit" value="Submit"/> </div> </div> </form> {% endblock %} Views like this.. def input_form(request): if request.method == 'POST': form = InForm(request.POST) else: form = InForm() return render(request, 'SeqData/in_form.html', {'form': form}) def result_page(request): form = InForm(request.POST) if form.is_valid(): val1 = form.cleaned_data['start_year'] val2 = form.cleaned_data['end_year'] val3 = form.cleaned_data['country'] if val1 <= val2: IDs = SequenceDetails.objects.all().filter(country=val3).filter(year__range =[val1,val2]) return render(request,'SeqData/slider.html',{'IDs':IDs}) else: return render(request,'SeqData/ERROR.html',{'val1':val1, 'val2':val2}) project URL.py like this.. urlpatterns = [ url(r'^cholera/', include('table.urls'), name='cholera'), url(r'^cholera/', include('DATAPLO.urls')), url(r'^cholera/', include('SeqData.urls')), ] Application URL.py like this.. from django.conf.urls import url from . import views urlpatterns = [ url(r'^SeqData/$', views.input_form, name='input_form'), url(r'', … -
Whether serving HTML as a static file is recommended in Django?
We have AngularJS and Django based web app. The app will have different portals for a different type of users. Currently, whenever a user is logged in, depending on their user type the response will be a static HTML file.Once it is served the angular will make an API call to get the current user details and with that subsequent API calls will be made(When 403 occurs it is planned to close the session from angularjs and redirect the user to login/correct dashboard). Since the HTML is served as static all the static assets will be directly server(not via Django). We are also planning to use push notifications(django-channels). I want to understand whether the process followed is recommended? The other option is setting user variable in base Dashboard html(html response from a successful login) and depending on that user type variable angularjs will render the corresponding view within the dashboard html, api calls will also be made by accessing user variable set by Django in the base dashboard. I would like to understand the advantages and disadvantages of both these options and which is recommended. P.S I prefer option 2 -
Django FileUpload choice inside of a dropdown (ModelChoiceField)
Hi is it possible to put a choice inside of a dropdown and when it is clicked it will allow user to upload file, right now I have a dynamic dropdown built using ModelChoiceField but I want to add a choice that will allow the user to upload the file if they don't want to choose to use the default choices. Something like the one in the picture but when the '------------' choice is clicked it will pop up something that will allow user to upload file. Image example I've been looking for the answer but couldn't find one unfortunately. thanks. -
User Model Signal Call to flag a user in a table
I'm trying to solve a problem where a user logs in with their windows NT login and if they fall within a list of NT names in another table in the model / existing database table I'd like to flag them as a CFO by placing a 1 in the is_cfo field. Is it possible to do this way if not how would you solve this problem? The list of NTNames would be in the following model: class QvDatareducecfo(models.Model): cfo_fname = models.CharField(db_column='CFO_FName', max_length=100, blank=True, null=True) # Field name made lowercase. cfo_lname = models.CharField(db_column='CFO_LName', max_length=100, blank=True, null=True) # Field name made lowercase. cfo_ntname = models.CharField(db_column='CFO_NTName',primary_key=True, serialize=False, max_length=7) # Field name made lowercase. cfo_type = models.IntegerField(db_column='CFO_Type', blank=True, null=True) class Meta: managed = False db_table = 'QV_DataReduceCFO' My User model uses LDAP authentication and pulls the Users information from AD into the following model: class User(AbstractBaseUser, PermissionsMixin): email = models.EmailField(unique=True) username = models.CharField(max_length=7, unique=True) formattedusername = models.CharField(max_length=11, unique=True, primary_key = True) first_name = models.CharField(max_length=40) last_name = models.CharField(max_length=140) date_joined = models.DateTimeField(default=timezone.now) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=False) is_cfo = models.BooleanField(default=False) facility = models.CharField(max_length=140) officename = models.CharField(max_length=100) jobdescription = models.CharField(max_length=140) positioncode = models.CharField(max_length = 100) positiondescription = models.CharField(max_length=140) coid = models.CharField(max_length=5) streetaddress = models.CharField(max_length=140) title … -
How to dispalay icons of django site after deploying
Hello I recently deployed a django website on heroku and used aws to store my media and static files, the site was deployed successfully except i cant find the icons used by the template on production but those icons work locally what can i do to solve this. Thank you in anticipation of your favourable response -
Django - Save modelformset data to session in CBV
Goal: I'm trying to save modelformset data to session. I have a view where a same set of form fields need to be filled out for items chosen from a checkbox in a previous view. Problem: My modelformset somehow returns only the last set of inputs is passed after cleaned_data (but I can see all inputs in request.POST). I don't get validation or any kind of errors (If I switch the inputs, the input that was passing before does not pass cleaned_data) request.POST <QueryDict: {'form-TOTAL_FORMS': ['1'], 'form-INITIAL_FORMS': ['0'], 'form-MIN_NUM_FORMS': ['0'], 'form-MAX_NUM_FORMS': ['1000'], 'csrfmiddlewaretoken': ['#abbr', '#abbr', '#abbr'], 'form-0-pd_month': ['8', '5', '7'], 'form-0-pd_day': ['28', '28', '28'], 'form-0-pd_year': ['2017', '2017', '2017'], 'form-0-var': ['t1', 't2', 't3'], 'form-0-id': ['', '', '']}> cleaned_data {'pd': datetime.date(2017, 7, 28), 'var': 't3', 'id': None} I checked In a Django Formset being returned in a Post, all Forms are showing all fields changed even though none have Django save only first form of formset Django formset only adding one form Only last label input value being returned in Django and 100 more as well as Django doc but none of these work for me. Code: I pasted as minimal code as possible without compromising the big picture. views.py #checklist view … -
How to write a test case for this Django custom tag
Django version : v1.10 I found this answer in order to have a if-else tag to compare the request.path in Django templates https://stackoverflow.com/a/19895344/80353 from django import template from django.template.base import Node, NodeList, TemplateSyntaxError register = template.Library() class IfCurrentViewNode(Node): child_nodelists = ('nodelist_true', 'nodelist_false') def __init__(self, view_name, nodelist_true, nodelist_false): self.view_name = view_name self.nodelist_true, self.nodelist_false = nodelist_true, nodelist_false def __repr__(self): return "<IfCurrentViewNode>" def render(self, context): view_name = self.view_name.resolve(context, True) request = context['request'] if request.resolver_match.url_name == view_name: return self.nodelist_true.render(context) return self.nodelist_false.render(context) def do_ifcurrentview(parser, token): bits = token.split_contents() if len(bits) < 2: raise TemplateSyntaxError("'%s' takes at least one argument" " (path to a view)" % bits[0]) view_name = parser.compile_filter(bits[1]) nodelist_true = parser.parse(('else', 'endifcurrentview')) token = parser.next_token() if token.contents == 'else': nodelist_false = parser.parse(('endifcurrentview',)) parser.delete_first_token() else: nodelist_false = NodeList() return IfCurrentViewNode(view_name, nodelist_true, nodelist_false) @register.tag def ifcurrentview(parser, token): """ Outputs the contents of the block if the current view match the argument. Examples:: {% ifcurrentview 'path.to.some_view' %} ... {% endifcurrentview %} {% ifcurrentview 'path.to.some_view' %} ... {% else %} ... {% endifcurrentview %} """ return do_ifcurrentview(parser, token) Was wondering if there's a way to write test case to cover this custom code? I want to maintain our test coverage percentage -
Tests for DRF with MongoDB
I would like to ask about testing approach to DRF with MongoDB. I am interested in test my endpoints, but modules like APIRequestFactory() or APIClient() don't work with NoSQL database. Maybe someone knows how to test endpoint using some DRF module? Thanks in advance -
Django Form does not seem to be updating
I have a simple form that im updating via template, however when I hit the submit button, the content of the config text area looks to have updated, however if I refresh the page, the old content returns. im not sure if the code in the view is processing the changes correctly or not, am I missing something? Thanks @login_required @user_passes_test(lambda u: u.has_perm('config.can_change_configtemplate')) def edit_template(request, template_id): template = get_object_or_404(ConfigTemplates, pk=template_id) # create a new form form = EditTemplateForm(request.POST or None, instance=template) if form.is_valid(): form.save() return render(request, 'config/edit_template.html', { 'TemplateForm': form, }) template: <form id="edit_template" action="" method="post"> {% csrf_token %} <table> <tr> <td coslpan="2">{{ TemplateForm.template_name.label }}: {{ TemplateForm.template_name }}</td> </tr> <tr> <td> {{ TemplateForm.config.label }}: </br> {{ TemplateForm.config }} </td> <td> <h3>Variables:</h3> <ul class="variable"> {% for data in Variables %} <li>{{ data }}</li> {% if forloop.counter|divisibleby:25 %} </ul> <ul class="variable"> {% endif %} {% endfor %} </ul> </td> </tr> <tr> <td> {{ TemplateForm.remote_config.label }}: </br> {{ TemplateForm.remote_config }} </td> <td>&nbsp; </td> </tr> </table> <div class="update-footer"> <input type='submit' value='Update Template' /> </div> -
Create new AutoField using migration
From collegues I inherited multiple identical MySQL databases. Using DJANGO's inspectdb I derived the data models for it, and created a web interface to view the data. When instantiating the model structure again, DJANGO failed to create a unique_together contraint for 2 fields. Problem: I want to get rid of the existing unique_together and the 2 primary keys, as DJANGO does not support mutiple primary keys. For example with the DJANGO auto generated id field (as primary key). Is this possible, and how should I do it? Writing a custom migration would be an option, but how? Contraints Data loss is not an option, so I cannot just drop tables. Also the migration history should be maintained. What I have is: class MyModel(models.Model): sessionid = models.ForeignKey('Session', models.DO_NOTHING, db_column='sessionID', primary_key=True) datetime = models.BigIntegerField(primary_key=True) class Meta: unique_together = (('sessionid', 'datetime'),) But it should become something like: class MyModel(models.Model): sessionid = models.ForeignKey('Session', models.DO_NOTHING, db_column='sessionID') datetime = models.BigIntegerField() Any help is highly appreciated! -
Django 1.11.7 - staticfiles_dir issue
I'm developing with django first time. I have read what is : STATIC_ROOT / STATICFILES_DIR / STATIC_URL, I know what purpose for each of them. I have a problem which I keep getting 404 on browser trying to get the css files. setting.py BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(file))) PROJECT_DIR = os.path.dirname(os.path.abspath(file)) STATIC_URL = '/static/' STATIC_ROOT = '%s/online_static/' % (BASE_DIR) STATICFILES_DIRS = ['%s/bootstrap/' % (PROJECT_DIR),] index.html <head> {% load staticfiles %} <meta charset="UTF-8"> <title>{% block title%}Default title{% endblock title %}</title> <meta name="description" content="{% block metadescription%}{% endblock metadescription %}"> <meta name="keywords" content="{% block metakeywords%}{% endblock metakeywords %}"> <meta name="author" content="alme7airbi9357@gmail.com"> <!-- Bootstrap core CSS --> <link href="{% static 'vendor/bootstrap/css/bootstrap.min.css' %}" type="text/css" rel="stylesheet"> <!-- Custom styles for this template --> <link href="{% static 'css/shop-homepage.css' %}" rel="stylesheet" type="text/css"> <!-- Bootstrap core JavaScript --> <script src="{% static 'vendor/jquery/jquery.min.js' %}"></script> <script src="{% static 'vendor/bootstrap/js/bootstrap.bundle.min.js' %}"></script> </head> what I did after setting this params I have run the python manage.py collectstatic Note : DEBUG = False -
Django's prefetch_related and select_related on more complex relationships in Admin
I have a somewhat complex relationship between multiple models. A simplified example: class Country(models.Model): name = models.CharField([...]) [...] def __ str__(self): return f'{self.name}' class Region(models.Model): country = models.ForeignKey(Country) name = models.CharField([...]) [...] def __ str__(self): return f'{self.name}' class CityManager(models.Manager): def get_queryset(self): return super().get_queryset().select_related('region', 'region__country') class City(models.Model): name = models.CharField([...]) region = models.ForeignKey(Region) objects = CityManager() def __str__(self): return f'{self.region.country} - {self.region} - {self.name}' Hence when I want to display some kind of list of cities (e.g. list all cities in Germany), I have to use select_related to be even remotely efficient otherwise I query for Country each time the __str__ is called. This is not the problem. The problem is that when I have unrelated group of models and I want to FK to City, such as: class Tour(models.Model): [...] class TourItem(models.Model): tour = models.ForeignKey(Tour) city = models.ForeignKey(City) [...] Tour would represent a planned tour for some music band; and TourItem would be a specific tour in a given city. I have a simple admin interface for this, so that TourItem is an inline field for the Tour (ie. so multiple tour items can be edited/added simultaneously). The problem is that now there are multiple queries firing for same Country … -
pycharm importable Django
This question has been asked here: Pycharm error Django is not importable in this environment However my requirement is more specific. Sadly, our repo has a copy of Django inside it for some long lost legacy versioning requirement which probably originated from the muffled gargles of a previous developer choking on her coffee being mistaken for approval of this idea. Let's say it isn't feasible for django to exist anywhere but the src folder of this project (for now) ... How can I get Pycharm to stop complaining about this every time I launch tests or anything else? The 2 seconds to close that dialog are quickly adding up. -
Is it possible to build a Case, When statement as string and run it in annotation
I am trying to dynamically build an expression and annotate it to query result. the code is: annotate_string = "Case(" for any_threshold in Threshold.objects.all(): annotate_string += "When(Possibility__lte= F('%i'),Intensity__lte= F('%i'),then=Value(F('%s'))),"\ %(Avalue,Bvalue,label) annotate_string += "default=Value(''))," and in the query I have: query.annotate( label = annotate_string ) However the error I get is: AttributeError: 'str' object has no attribute 'resolve_expression' I tried to use eval() or exec() to make string executable. P.S: You can find the question that led to this one here. -
how to create a field in django that is only enabled after filling in the previous one?
I want to enable in django admin the "registration" field only if "bond" is filled in as "outsourced". class Contato(models.Model): BOND_CHOICES = ( ('server', 'Servidor'), ('outsourced', 'Terceirizado'), ('trainee', 'Estagiário'), ) name = models.CharField(verbose_name='Nome', max_length=100) date = models.DateField(verbose_name='Data de Nascimento') email = models.CharField(verbose_name='Email', max_length=100) branchLine = models.DecimalField(verbose_name='Ramal', max_digits=4, decimal_places=0) bond = models.CharField(verbose_name='Vínculo', max_length=10, choices=BOND_CHOICES) registration = models.CharField(verbose_name='Matrícula', max_length=20) -
How to pagination the nested-relationships?
I read the django-rest-framework nested-relationships : You can see the tracks in AlbumSerializer: class TrackSerializer(serializers.ModelSerializer): class Meta: model = Track fields = ('order', 'title', 'duration') class AlbumSerializer(serializers.ModelSerializer): tracks = TrackSerializer(many=True, read_only=True) class Meta: model = Album fields = ('album_name', 'artist', 'tracks') The official website do not give a method to pagination the tracks in AlbumSerializer, if the tracks count is too large, how to realize the pagination for tracks? -
Transfer pandas df to db.sqlite3 using django models
I have the following df: Year JAN FEB MAR APR MAY JUN JUL AUG SEP 0 1910 6.1 7.2 8.9 9.6 14.5 17.1 17.3 16.9 15.6 1 1911 5.8 6.5 7.5 9.7 16.2 17.8 21.7 21.4 17.3 2 1912 6.0 7.5 9.1 12.5 14.4 16.0 18.4 15.0 13.7 3 1913 6.7 7.2 8.5 10.4 13.8 16.5 17.6 18.5 16.5 I need to put it into the sqlite3 database that comes with django using the following models: from django.db import models from django.core.validators import MaxValueValidator, MinValueValidator class Location(models.Model): LOCATIONS = ( ('EN', 'England'), ('SC', 'Scotland'), ('WA', 'Wales'), ('UK', 'United Kingdom'), ) location = models.CharField(max_length=2, choices=LOCATIONS) class Meta: verbose_name_plural = "Location" def __str__(self): return self.location class Max_temp(models.Model): location = models.ForeignKey(Location, on_delete=models.CASCADE) year = models.IntegerField( default=0, validators=[MaxValueValidator(9999), MinValueValidator(0)] ) MONTH_OR_SEASON = ( ("JAN", "January"), ("FEB", "February"), ("MAR", "March"), ("APR", "April"), ("MAY", "May"), ("JUN", "June"), ("JUL", "July"), ("AUG", "August"), ("SEP", "September"), ("OCT", "October"), ("NOV", "November"), ("DEC", "December"), ("WIN", "Winter"), ("SPR", "Spring"), ("SUM", "Summer"), ("AUT", "Autumn"), ("ANN", "Annual"), ) month_or_season = models.CharField(max_length=3, choices=MONTH_OR_SEASON) class Meta: verbose_name_plural = "Maximum Temperature" def __str__(self): return self.year class Min_temp(models.Model): location = models.ForeignKey(Location, on_delete=models.CASCADE) year = models.IntegerField( default=0, validators=[MaxValueValidator(9999), MinValueValidator(0)] ) MONTH_OR_SEASON = ( ("JAN", "January"), ("FEB", "February"), ("MAR", "March"), … -
How to return the Comment list by WorkOrder?
I have such a case: I have a WorkOrder class: class WorkOrder(models.Model): workorder_num = models.CharField(max_length=64, help_text="workorder number") name = models.CharField(max_length=32, help_text="name") content = models.TextField(help_text="content") And I also have a WorkOrderComment class: class WorkOrderComment(models.Model): """ comment """ workorder = models.ForeignKey(WorkOrder, help_text="belong to which order" ) comment_user = models.OneToOneField(User, help_text="comment user") content = models.CharField(max_length=256, help_text="content") So, there is a requirement, I want to list the workorder comments, so I write the serializers and views: serializer: class WorkOrderCommentSerializer(ModelSerializer): class Meta: model = WorkOrderComment fields = "__all__" view: class WorkOrderCommentListAPIView(ListAPIView): serializer_class = WorkOrderCommentSerializer permission_classes = [] queryset = WorkOrderComment.objects.filter() But if I list workorder comment, you know it will list all the comments, no organization. I want to through workorder to get its comments how to do with that? -
How is MultiValueDictKeyError and AttributeError related in Django here?
I have a function in Django that I am trying to solve from my previous question here. While trying out my own solutions, I have made significant updates but I encounter an error. I'm trying this out right now: def view_routes(request, query=None): routes = None if query is None: routes = Route.objects.all() else: #View: Routes in Queried Boundary if request.method == 'POST': return HttpResponse("OK") elif request.method == 'GET': json_feature = json.loads(request.GET.get('geo_obj', False)) #json_feature = json.loads(request.GET['geo_obj']) geom = make_geometry_from_feature(json_feature) routes = Route.objects.filter(wkb_geometry__within=geom[0]) print("Total Routes Filtered: " + str(Route.objects.filter(wkb_geometry__within=geom[0]).count())) #Render to Django View routes_json = serialize('geojson', routes, fields=('route_type', 'route_long', 'route_id', 'wkb_geometry',)) routes_geojson = json.loads(routes_json) routes_geojson.pop('crs', None) routes_geojson = json.dumps(routes_geojson) #return render(request, 'plexus/view_routes.html', {'routes':routes}) return redirect('routes_view', query) I am having trouble switching/commenting out between these two lines: json_feature = json.loads(request.GET.get('geo_obj', False)) json_feature = json.loads(request.GET['geo_obj']) Both presents an error respectively: TypeError: the JSON object must be str, not 'bool' django.utils.datastructures.MultiValueDictKeyError: "'geo_obj'" -
Django cant find pip3 installed module
I created a Python module and installed it using pip3. If i check on dist-package folder its there. If i import this module into a new Python project its ok. Problem: I would like to use this module on my Django project, but when i try to import it can't be found. Already tried: If i copy the module to site-package, it works but i don't get why i have to do this. I would like that this Python module installed with pip3 is visible for everyone without the need to copy/paste from dist folder. -
Multiple dropdown menu filter in html using Django
I am new to Django and trying to create a view where the user can have options to select the values. Can someone guide on how to proceed with it? I have attached the model for your reference, the user should be able to select the value for the BU, Team,Level, Product and Channel. Also, on selecting BU the teams should get updated and so on. Please suggest. class Master_Table(models.Model): Key_Variable=models.CharField(max_length=255,primary_key=True) BU = models.CharField(max_length=20) Team = models.CharField(max_length=20) Level = models.CharField(max_length=20) Product= models.CharField(max_length=20) Channel = models.CharField(max_length=20)