Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
HTML pause with multiple audio players
I currently have multiple audio players on my webpage. These links are random, since they are obtained through an API and rendered in a loop (this is done in a django template). It looks like this: {% for item in audio_files %} <audio controls> <source src="{{ item.audio }}" type="audio/mpeg"> </audio> {% endfor %} I have multiple of those on my page, but when I play one first and I click play on the other one(s), they play through eachother. I'd very much like for it to be able to only play one audio track (pause the first one when clicking another). Any idea how to go about this? -
Javascript File Select not updating image on page?
I am working on a web app which was created by a colleague and am trying to fix an image upload issue. Basically, the webpage has a section where the user can upload a profile image. When the user clicks upload the file browser opens, you can select an image file and then that image file is opened in a cropping tool. This is all working as intended, however, if the user does not click on the cropping area at least once before clicking save the image does not update on the page. I'm not sure why the image is not updating on the page unless you click on the cropping area at least once. Any ideas? Here is the code which does the updating of the image on the page. <script type="text/javascript"> var selDiv = ""; document.addEventListener("DOMContentLoaded", init, false); function init() { document.querySelector('#changeAvatar').addEventListener('change', handleFileSelect, false); selDiv = document.querySelector("#selectedFiles"); } function handleFileSelect(e) { if(!e.target.files || !window.FileReader) return; selDiv.innerHTML = ""; var files = e.target.files; var filesArr = Array.prototype.slice.call(files); filesArr.forEach(function(f) { if(!f.type.match("image.*")) { return; } var reader = new FileReader(); reader.onload = function (e) { var html = "<div class='add-image'><img src=\"" + e.target.result + "\">" + "<br clear=\"left\"/></div>"; selDiv.innerHTML += html; … -
django-autocomplete-light error = 'list' object has no attribute 'queryset'
i am new on django and i need your help, trying since many days to understand django-autocomplete-light, after setup my test, http://192.168.0.108:8000/country-autocomplete/ work, data is showed like explaned here http://django-autocomplete-light.readthedocs.io/en/master/tutorial.html#overview But after following next step, i am getting error: AttributeError at /auto 'list' object has no attribute 'queryset' Request Method: GET Request URL: http://192.168.0.108:8000/auto Django Version: 1.10.3 Exception Type: AttributeError Exception Value:'list' object has no attribute 'queryset' Exception Location: /home/alcall/ENV/lib/python3.4/site-packages/dal/widgets.py in filter_choices_to_render, line 161 Bellow my setup: ----------#ulrs from dal import autocomplete from django.conf.urls import url from django.contrib import admin from rates.view.index import * from rates.view.index import UpdateView urlpatterns = [ url(r'^admin/', admin.site.urls), url( r'^country-autocomplete/$', CountryAutocomplete.as_view(), name='country-autocomplete', ), url(r'^autos?$', UpdateView.as_view(), name='select', ), ] --------#models.py from __future__ import unicode_literals from django.db import models class Country(models.Model): enabled = models.IntegerField() code3l = models.CharField(unique=True, max_length=3) code2l = models.CharField(unique=True, max_length=2) name = models.CharField(unique=True, max_length=64) name_official = models.CharField(max_length=128, blank=True, null=True) prix = models.FloatField() flag_32 = models.CharField(max_length=255, blank=True, null=True) flag_128 = models.CharField(max_length=255, blank=True, null=True) latitude = models.DecimalField(max_digits=10, decimal_places=8, blank=True,$ longitude = models.DecimalField(max_digits=11, decimal_places=8, blank=True$ zoom = models.IntegerField(blank=True, null=True) class Meta: managed = False db_table = 'country' def __str__(self): return self.name --------#view (include form too) from dal import autocomplete from django.shortcuts import render from rates.models import Country from … -
Django system-wide install to virtualenv
I've recently deployed an application online using DigitalOcean single-click droplet setup which setup Django on Ubuntu with nginx and gunicorn. It came with a default django project which I've managed to change to my own. However, the default project doesn't use a virtualenv, it uses a system-wide install. So, the app only works if all the dependencies are installed on the system. I know this because if I uninstall django, it gives me an internal server error. I would like to use the python in my virtualenv as the interpreter. And refer to the site-packages in that environment. I've tried fiddling with the PYTHONPATH and adding sys.path.append('/home/env/projectname') to the wsgi file but this doesn't work. How can I achieve this? -
Django Submit Form Working Development Not Deployment
I have a form that creates a new blog post and redirects me to that blog post. The form works properly in development but when I deployed the app to Heroku and click the submit button nothing happens. Is something wrong with the database, my form, or the admin functionality (which is required to access the form)? In terms of the database (in case it has anything to do with that) I put a .dump on Amazon S3 and pushed it to my Heroku Postgres database. Any help would be great! Relevant section from views.py: @login_required def post_new(request): if request.method == "POST": form = PostForm(request.POST) if form.is_valid(): post = form.save(commit=False) post.author = request.user post.save() if post.category == 'progresstracker': return redirect('books.views.pt_detail', slug=post.slug, category=post.category) elif post.category == 'resources': return redirect('books.views.resources') else: return redirect('books.views.bt_detail', slug=post.slug, category=post.category) else: form = PostForm() return render(request, 'blog/post_edit.html', {'form': form}) def pt_detail(request, slug, category): post = get_object_or_404(Post, slug=slug, category__slug=category) template = CATEGORY_TEMPLATES.get(post.category.slug) return render(request, template, {'post': post}) The form: {% extends 'blog/base.html' %} {% block nav %} <li><a href="/home">Home</a></li> <li><a href="/progresstracker">Progress Tracker</a></li> <li class="dropdown"> <a href="/blogtopics" class="dropbtn">Blog Topics</a> <div class="dropdown-content"> <a href="/blogtopics/computer-science">Computer Science</a> <a href="/blogtopics/data-science">Data Science</a> <a href="/blogtopics/other">Other</a> </div> </li> <li><a href="/resources">Resources</a></li> {% endblock %} {% block content … -
Django extra context item in HttpResponse
I have my view defined as follow: class HomeView(TemplateView): template_name = "home.html" def get_context_data(self, **kwargs): context = super(HomeView, self).get_context_data(**kwargs) context['items'] = Item.objects.all() return context def get(self, request, *args, **kwargs): #Getting data from an api call here response = api.get_some_items() list_with_items = [] for i, item in enumerate(response): list_with_items.append(item.name) template = loader.get_template('home.html') context = self.get_context_data(**kwargs) context['items'] = list_with_items return HttpResponse(template.render(context, request)) In the template I loop through the list as follow, but it does not seem to render anything from that context, which I know because I put the {% empty %} tag in there. {% for item in items %} {{ item }} {% empty %} <p>No items</p> {% endfor %} What does go wrong here? -
How to use data from oneToMany models from sqlite3 in Django and reportlab?
i'm learning python, django and reportlab. I'm trying to export a pdf with some info from a sqlite database. I've looked for info like this on different sites, documentation and youtube tuts, and didn't find anything, i've tried some code based on another part of my project that displays the data from my database and tried to make it work with reportlab, but can't. When i run it, it throws an error saying: 'ReverseManyToOneDescriptor' object is not iterable I'm on Django 1.10 My code goes as follows: models.py ... class proy(models.Model): nombre = models.CharField(max_length=250) ... class escena(models.Model): fromProy = models.ForeignKey(proy, on_delete=models.CASCADE) ... views.py ... from .models import proy, escena ... def expGuion(request, proy_id): ... for escena in proy.escena_set: c.drawString(50,750,escena.Nro_escena) INT_EXT = models.CharField(max_length=8) ... I have all the imports necessary and i can export pdfs, the problem is when i have to go trough the data in models proy and escena. I would like to show the data from each escena in proy, but can't find how to do this. I've read the documentation on reportlab, and django, but can't find one that talks about both together. As i said, i'm new to this and i would be so grateful if … -
Django rest swagger 'get' response model
I am using django-rest-framework==3.5.3 and django-rest-swagger==2.1.0. How can i have response model in present in swagger UI. Here http://petstore.swagger.io/#!/pet/findPetsByStatus in get methods we can see response model. In my case, there is only HTTP Status Code. Is there a way to achieve it in django-rest-swagger? -
Website user system without passwords
I am building a new content-managing web app in django. There is a lot of media tied to the default user in the django system. I want to use google's firebase for authenticating users. The user authenticates on their servers and sends my page a callback with a user object (email, name, etc). I need to create a corresponding user object on the django site. I feel like I do not need to use passwords at all. Once receiving the user object from the firebase callback, I can just just start the user's session without actually authenticating the user using a password in django. I know that questions like this have too much to do with opinion. But what I am really looking for is if someone can tell if you can see this blowing up in my face. Like is there an obvious logical gap here? Do I always need to use the password to authenticate? Thank you. -
Django ModeForm: no fields error
I have used the code in django 1.6 but when trying it in django 1.8.6 I get: AttributeError: 'SignupDataForm' object has no attribute 'fields' at this line, but also generaly whenever asking for fields: merged_field_order = list(self.fields.keys()) My SignupDataForm is a child declared like this: class SignupDataForm(BaseUserDataForm): reg_user_badge = forms.CharField(label="Give Points to a Friend",required=False,widget = TextInput(attrs={'placeholder': 'Username (optional)'}),validators=[validate_friendname]) class Meta(BaseUserDataForm.Meta): model = UserData fields = BaseUserDataForm.Meta.fields + ('terms_conditions',) #terms_conditions is also a model field but not added to the parent definition def __init__(self, *args, **kwargs): super(SignupDataForm, self).__init__(*args, **kwargs) self.fields['terms_conditions'].required = False self.fields['gender'].widget = Select(choices=GENDER_CHOICES,attrs={'class':'signup_select',}) self.fields['password2'].widget.attrs['onblur'] ="check_pass()" self.fields['password1'].widget.attrs['onblur'] ="check_pass()" def clean(self): #clean overwrite What is weird is that if I use the parent form everything works fine, I get no error. Also if I place a print fields in the META declaration the tuple with fields is there. The shortend code for the parent is here: class BaseUserDataForm(forms.ModelForm): url = forms.CharField(max_length = 30, label="Don't type here (anti spam protection)",validators=[validate_name_honeypots]) class Meta: model = UserData fields = ('****model fields named without terms_conditions field****') def __init__(self, *args, **kwargs): super(BaseUserDataForm, self).__init__(*args, **kwargs) The error occurs in another child: class BaseSignupForm(SignupDataForm): username = forms.CharField(label=_("Username"), max_length=get_username_max_length(), min_length=app_settings.USERNAME_MIN_LENGTH, widget=forms.TextInput( attrs={'placeholder': _('Username'), 'autofocus': 'autofocus'})) email = forms.EmailField(widget=forms.TextInput( attrs={'type': … -
Dynamic addition of fields to a django form through user action
I'm working with django and want to give the user the option to input an arbitrary number of strings into the form and then save this to a database. What it actually is, is a setup page for a teacher to create a new homework exercise for a student, and if the submission is selected as electronic, the teacher then needs to specify the required filenames + extensions that need to be submitted. So by default only one char field is visible when electronic submission is selected, but I would like a little plus button next to it to display a new char field below where the teacher can enter a second required filename to be submitted. And another click to add 3rd and so on. Is this possible and how could i go abut doing this? I could use a TextField and split by new lines, but it wouldn't look as good as dynamic char fields. And the problem with dynamic adding fields to from when rendered is I don't know the number until after its rendered and teacher selects electronic AND clicks the plus button some unknown number of times. -
Django manage.py 1.6.11 suddenly crashes when importing settings
I have an old DJango application that used work fine but suddenly crashes. I use to test it with: cd /opt/formshare/src/formshare/ export PYTHONPATH=$PYTHONPATH:/opt/formshare/src/formshare export DJANGO_SETTINGS_MODULE=formshare.settings.default_settings python manage.py validate But now I get this error: (formshare) bash-4.3$ python manage.py validate Your environment is:"formshare.settings.default_settings" Traceback (most recent call last): File "manage.py", line 21, in <module> execute_from_command_line(sys.argv) File "/opt/formshare/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line utility.execute() File "/opt/formshare/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/opt/formshare/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command commands = get_commands() File "/opt/formshare/lib/python2.7/site-packages/django/core/management/__init__.py", line 107, in get_commands apps = settings.INSTALLED_APPS File "/opt/formshare/lib/python2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__ self._setup(name) File "/opt/formshare/lib/python2.7/site-packages/django/conf/__init__.py", line 49, in _setup self._wrapped = Settings(settings_module) File "/opt/formshare/lib/python2.7/site-packages/django/conf/__init__.py", line 132, in __init__ % (self.SETTINGS_MODULE, e) ImportError: Could not import settings 'formshare.settings.default_settings' (Is it on sys.path? Is there an import error in the settings file?): cannot import name OrderedDict I am using: virtualenv=15.0.2 Python=2.7.11 amqp==2.1.1 billiard==3.3.0.23 celery==3.1.15 dict2xml==1.3 Django==1.6.11 django-braces==1.10.0 django-celery==3.1.16 django-cors-headers==0.13 django-db-readonly==0.3.2 django-digest==1.13 django-filter==0.7 django-guardian==1.2.4 django-nose==1.4.2 django-oauth-toolkit==0.7.2 django-registration-redux==1.1 django-reversion==1.8.4 django-taggit==0.12.1 django-templated-email==0.4.9 djangorestframework==2.4.3 djangorestframework-csv==1.3.3 dpath==1.2.post70 elaphe==0.5.6 FormEncode==1.3.1 gdata==2.0.18 httmock==1.2.2 httplib2==0.9 jdcal==1.3 jsonfield==0.9.23 kombu==4.0.0 librabbitmq==1.5.2 linecache2==1.0.0 lxml==3.4.0 Markdown==2.5 mock==1.0.1 modilabs-python-utils==0.1.5 nose==1.3.7 numpy==1.11.2 oauthlib==2.0.1 openpyxl==2.0.5 pandas==0.12.0 Pillow==2.5.3 poster==0.8.1 psycopg2==2.5.4 pybamboo==0.5.8.1 pylibmc==1.3.0 pymongo==2.7.2 python-dateutil==2.6.0 python-digest==1.7 -e git+https://github.com/qlands/python-json2xlsclient.git@5a39387752d819cb6387f75569dbea9a5288aa6f#egg=python_json2xlsclient pytz==2014.7 -e git+https://github.com/XLSForm/pyxform.git@cfe8589f40319fa3279b0a83e0d23d49bcbe8408#egg=pyxform recaptcha-client==1.0.6 requests==2.4.1 savReaderWriter==3.4.2 simplejson==2.6.2 six==1.10.0 South==1.0 traceback2==1.4.0 unicodecsv==0.9.4 … -
Django Displaying images from Database
So I'm new to Django. I'm also using Bootstrap. I've made a database that holds url, captions and stories. And I have a web template ready (html/css) My problem is how am I going to get the url from db and put it in a div in html as an image and also display all inputs (captions' photos and stories) in pub_date row (oldest on top)? -
How to make a request in DRF that points to another API endpoint in same Django app
very quick question that is how to nest request in Django-rest-framework. I have end point A that I make POST on and want to make another request to point B in it's serializer perform_create method. This API end points are actually written in same Django application. Serializer for API A class ReadingCreate(CreateAPIView): permission_classes = [IsOwnerOrReadOnly] serializer_class = ReadingCreateSerializer def perform_create(self, serializer): #HERE I WANT TO MAKE REQUEST TO POINT B serializer.save(user_profile= UserProfile.objects.get(user=self.request.user)) I am familiar with library such as request but I seems there is a better way since, I also need to send token for authentication and I am like in same file. This problem seems simple but I clearly don't know how to do it properly. -
Extend django admin template
I'm trying to add a custom button in change_list django admin page next to the add object in the top of the page. {% extends "admin/change_list.html" %} {% load i18n %} {% block object-tools-items %} {{ block.super }} <li> <button class="" href="...">Click Here!</button> </li> {% endblock %} I followed a lot of tutorials but with no success. I have 'APP_DIRS': True, in my settings.py and my project is like: project/ app/ templates/ change_list.html custom_template.html The custom_template.html is an Action in change_list, and it works. Am i missing something? Thanks. -
Failed with the get_object_or_404 django
This is the code: >>> from shortener.models import KirrURL >>> from django.shortcuts import get_object_or_404 >>> obj = get_object_or_404(KirrURL,shortcode='pric3e') Traceback (most recent call last):File"/Users/phil/Desktop/django110/lib/python3.5/site packages/django/shortcuts.py", line 85, in get_object_or_404 return queryset.get(*args, **kwargs) File "/Users/phil/Desktop/django110/lib/python3.5/site-packages/django/db/models/query.py", line 385, in get self.model._meta.object_name shortener.models.DoesNotExist: KirrURL matching query does not exist. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<console>", line 1, in <module> File "/Users/phil/Desktop/django110/lib/python3.5/site-packages/django/shortcuts.py", line 93, in get_object_or_404 raise Http404('No %s matches the given query.' % queryset.model._meta.object_name) django.http.response.Http404: No KirrURL matches the given query. >>> obj = KirrURL.objects.get(shortcode='pric3e') >>> obj <KirrURL: http://google.com> >>> obj.id 1 >>> obj.url 'http://google.com' I am practicing django model right now.The problem is when I used the get_object_or_404 trying to get the data which match the second key word argument it somehow failed.When I used get() method.It successes.I think I think I should get the same result here. -
Inline formset does not work only when the field is hidden in template
I'm using inline formset and I can't submit the form when one of the fields is hidden in template. {{ form.provider.as_hidden }} When the field is shown in the forms of the formset everything works normally. The field is properly populated and I can submit the form. {{ form.provider }} Any ideas what causes this issue? -
How to set initial choice for `ModelChoiceField` that was added in my form `__init__`?
Cannot figure out how to set initial choice for ModelChoiceField that was added in my form __init__. My forms.py: class MCQuestionForm(forms.ModelForm): class Meta: model = models.MultipleChoiceQuestion fields = ('prompt',) def __init__(self, *args, **kwargs): super(MCQuestionForm, self).__init__(*args, **kwargs) self.fields['choice'] = forms.ModelChoiceField(queryset=self.instance.mcqchoice_set.all(), widget=forms.RadioSelect, empty_label=None, ) MCQuestionFormSetForUser = modelformset_factory(models.MultipleChoiceQuestion, fields=('prompt',), form=MCQuestionForm, extra=0, widgets={ 'prompt': forms.TextInput( attrs={'readonly': True, 'class': 'borderless'}) } ) I want to do something like following in views.py to set default/initial choice: mcqs_formset_class = forms.MCQuestionFormSetForUser(prefix='mcq', initial={'choice': 0}) Is it not working because the field was added in the form __init__? -
relation does not exist error when extending on simple django_tables2 tutorial example
I am trying to follow this relatively simple tutorial for django-tables2. the tutorial isn't comprehensive and so I am a little lost as to what is causing my error although I should note that it is from me attempted to extend upon the tutorial. I am a beginner at django so I am just trying to learn. I am getting an error: ProgrammingError at /table_test relation "demo_query" does not exist LINE 1: SELECT COUNT(*) AS "__count" FROM "demo_query" ^ Request Method: GET Request URL: http://127.0.0.1:8000/table_test Django Version: 1.10.2 Exception Type: ProgrammingError Exception Value: relation "demo_query" does not exist LINE 1: SELECT COUNT(*) AS "__count" FROM "demo_query" Exception Location: C:\Users\zack\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\backends\utils.py in execute, line 64 and my files are here: http://pastebin.com/emhmbyxf -
How to make multi clickable forms in django python and then update the database of all together.
I have made the following django project. I have a form in my index.html file whose fields can be clicked using checkboxes. Upon clicking, it should update the database that his option has been marked and i am unable to do that. also please tell me how to make the form such that there is an option of select all and all fields get clicked and all are updated in the database at the same time. here is my code- index.html file - <h1>{{ student.name }}</h1> {% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %} {% for student in students_list %} <form action="{% url 'library:results' student.id %}" method="post">{% csrf_token %} <input type="checkbox" name="student" id="student{{ forloop.counter }}" value="{{ student.id }}"/> <label for="student{{ forloop.counter }}">{{ student.name }}</label><br/> {% endfor %} <input type="submit" value="clear" /> </form> views.py - from django.http import Http404 from django.shortcuts import render, get_object_or_404 from django.shortcuts import redirect from django.http import HttpResponse, HttpResponseRedirect from django.template import loader from .models import Student, Choice from django.urls import reverse from django.contrib.auth import authenticate, login from django.views.generic import View from .forms import USerForm def vote(request, student_id): student = get_object_or_404(Student, pk=student_id) try: selected_choice = Student.Choice_set.get(pk=request.POST['Choice']) except (KeyError, Choice.DoesNotExist): # Redisplay the question voting form. return render(request, … -
csrf_exempt when using django unfriendly urls not working
Django-unfriendly not recognising csrf_exempt when used in the app views. I have to either comment CsrfViewMiddleware or wrapping unfriendly urls with csrf_exempt as shown below urlpatterns = [ # Mostly unfriendly URL (but with SEO juice). url(r'^(?P<juice>.+)/(?P<key>.+)/$', csrf_exempt(views.deobfuscate), name='unfriendly-deobfuscate'), # Extremely unfriendly URL (no SEO juice). url(r'^(?P<key>.+)/$', csrf_exempt(views.deobfuscate), name='unfriendly-deobfuscate'), ] I know its not the best practice, suggest me with a solution -
Heroku + Django migrate command doesn’t create any table
As I know when running $heroku run python manage.py migrate it creates all tables from models.py. But my output looks different: the table wasn’t created or even mentioned. Operations to perform: Apply all migrations: findCharge Running migrations: Applying findCharge.0001_initial... OK Applying findCharge.0002_auto_20161124_1729... OK Applying findCharge.0003_auto_20161124_1955... OK Applying findCharge.0004_chargepoints_description... OK Anyway when I call $ heroku pg:psql and then ONYX=> \dt It looks like the table was created and “findCharge_chargepoints” in list of relations. … public | findCharge_chargepoints | table | owner_name … But when I type ONYX=> SELECT * FROM findCharge_chargepoints; ERROR: relation "findcharge_chargepoints" does not exist I was trying to run “python manage.py migrate” without app name, but result was the same. I run “makemigrations” on my local machine before pushing to git. I also was able to create superuser and I can open https://my-app-name.herokuapp.com/admin and add some data to db, but my app doesn’t see this data. Any suggestions? I’m sticking in it for 3 days now so I will be grateful for any help. P.S. I use heroku postgresql hobby-basic with postgis extension. -
Serialize a dictionary of Django objects
Ok, so the problem I am facing is: I know that there is a possibility to serialize "normal" python objects using: json.dumps(something) I know that you can serialize Django model objects using: serializers.serialize('json', obj) But how do I deal with mix of those: for example dictionary mapping ints to Django models? Is there any library that supports that? This is generally what I am trying to do in my programm. Place django models in complicated data structures (lists, dictionaries) representing a schedule and pass them to front-end by JSON. -
ImportError: No module named 'dash' for Django 1.10.3
Strange, this happened after i upgraded to 1.10.3 on Ubuntu 16. The old 0.9 worked fine for me. Reinstalled multiple times as well, no difference. ➜ Python projects and stuff django-admin startproject django_tutorial Traceback (most recent call last): File "/storage/programfiles/anaconda3/bin/django-admin", line 11, in <module> sys.exit(execute_from_command_line()) File "/storage/programfiles/anaconda3/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line utility.execute() File "/storage/programfiles/anaconda3/lib/python3.5/site-packages/django/core/management/__init__.py", line 316, in execute settings.INSTALLED_APPS File "/storage/programfiles/anaconda3/lib/python3.5/site-packages/django/conf/__init__.py", line 53, in __getattr__ self._setup(name) File "/storage/programfiles/anaconda3/lib/python3.5/site-packages/django/conf/__init__.py", line 41, in _setup self._wrapped = Settings(settings_module) File "/storage/programfiles/anaconda3/lib/python3.5/site-packages/django/conf/__init__.py", line 97, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/storage/programfiles/anaconda3/lib/python3.5/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 986, in _gcd_import File "<frozen importlib._bootstrap>", line 969, in _find_and_load File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 986, in _gcd_import File "<frozen importlib._bootstrap>", line 969, in _find_and_load File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked ImportError: No module named 'dash' Can't find anything on google, anyone have any ideas? :) -
Where to put function which isn't clearly view / admin / model related?
If I have an app which stores and displays pizza and topping data, and I want to create a function which creates pizzas (using some complex logic), where is the best place to put it? Should I create a separate file in the app called create_pizza.py, or is there some sort of best practice for adding this to the pizza model? I feel like it should be in a separate file, as it will be used by other apps within my project. Thanks for your advice.