Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Error importing module - ImproperlyConfigured: WSGI application
I created a Django project with an app named auth originally, but ran into some errors and changed it to authentication. Later, when trying to runserver I found out I couldn't because of the error: django.core.exceptions.ImproperlyConfigured: WSGI application 'coolwebsite.wsgi.application' could not be loaded; Error importing module: 'No module named 'django.contrib.authentication'' So I looked online and it turned out I shouldn't be naming apps with the same names as Django's app structure. I changed authentication to oauth and I'm still receiving the same error: django.core.exceptions.ImproperlyConfigured: WSGI application 'coolwebsite.wsgi.application' could not be loaded; Error importing module: 'No module named 'django.contrib.oauth'' I changed the app name to birds, but still I would get the same error. I don't understand why I am still receiving this error. The full error is: Traceback (most recent call last): File "C:\python3.6.3\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper fn(*args, **kwargs) File "C:\python3.6.3\lib\site-packages\django\core\management\commands\runserver.py", line 147, in inner_run handler = self.get_handler(*args, **options) File "C:\python3.6.3\lib\site-packages\django\contrib\staticfiles\management\commands\runserver.py", line 28, in get_handler handler = super(Command, self).get_handler(*args, **options) File "C:\python3.6.3\lib\site-packages\django\core\management\commands\runserver.py", line 68, in get_handler return get_internal_wsgi_application() File "C:\python3.6.3\lib\site-packages\django\core\servers\basehttp.py", line 57, in get_internal_wsgi_application sys.exc_info()[2]) File "C:\python3.6.3\lib\site-packages\django\utils\six.py", line 685, in reraise raise value.with_traceback(tb) File "C:\python3.6.3\lib\site-packages\django\core\servers\basehttp.py", line 47, in get_internal_wsgi_application return import_string(app_path) File "C:\python3.6.3\lib\site-packages\django\utils\module_loading.py", line 20, in import_string module = … -
Variables and attributes may not begin with underscores django template
Creating private filter solution works fine for this case {{ value|private:'_id' }} but for this case {% url 'value.show' value|private='_id' %} it doesn't work is there any way around this problem -
Django 2.0 and DRF 3.7.7 routers
I'm using Django 2.0 and DRF 3.7.7(novice with both) and trying to add URL patterns in app_config/urls.py: router = routers.DefaultRouter() router.register(r'^submit_free_account', SubmitFreeAccount, 'SubmitFreeAccount') app_name = 'app_config' #the weird code urlpatterns = [ path('getSourcesNodes', GetSourcesNodes.post, name='GetSourcesNodes'), path('getAppsNodes', GetAppsNodes.post, name='GetAppsNodes'), ] urlpatterns += router.urls And in main urls.py: urlpatterns = [ path('admin/', admin.site.urls), path('config/', include('app_config.urls', namespace='app_config')), ] So when I trying to request config/submit_free_account I have 404 errors with strange URL patterns tried by Django: config/ ^$ [name='api-root'] config/ ^\.(?P<format>[a-z0-9]+)/?$ [name='api-root'] How to add router URL patterns correctly in Django 2.0? -
Check members attribute using for loop
Guys I have a question that I guess simple but I do not know how to do it: In my app each project is link to a team that has several and each member need to answer a survey that is store in my data base inside "Response" I would like to show a jumbotron in my page only if all users have a Response in the data base. I tried : <div class="container paddingtop80 marginbottom30"> {% for member in project.team_id.members.all %} {% if member.response_set.count > 0 %} <div class="jumbotron greenback"> <h4>Welcome to the Project test "{{ project.name }}" Detail page</h4> </div> {% else %} <div class="jumbotron greenback"> <h4>Welcome to the Project "{{ project.name }}" Detail page</h4> </div> {%endif%} {% endfor %} <div class="container paddingtop80 marginbottom30"> {% for member in project.team_id.members.all %} {% if member.response_set.count > 0 %} <div class="jumbotron greenback"> <h4>Welcome to the Project test "{{ project.name }}" Detail page</h4> </div> {% else %} <div class="jumbotron greenback"> <h4>Welcome to the Project "{{ project.name }}" Detail page</h4> </div> {%endif%} {% endfor %} </div> the problem is that like you can see now my jumbotron is printed 3 times since I have 3 members. How can I check for the 3 … -
how to create the django-models for this sqlite database
I have 4 tables in the sqlite database. I need to create django models for these. enter image description here Mysql: -- Globals -- SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- SET FOREIGN_KEY_CHECKS=0; -- Table 'Tafseer' DROP TABLE IF EXISTS Tafseer; CREATE TABLE Tafseer ( id INTEGER NULL AUTO_INCREMENT DEFAULT NULL, tafseer MEDIUMTEXT NULL DEFAULT NULL, sura_id_Sura INTEGER NOT NULL, ayah_id_Ayahs INTEGER NOT NULL, nametafseer_id_NameTafseer INTEGER NOT NULL, PRIMARY KEY (id) ); -- Table 'Sura' DROP TABLE IF EXISTS Sura; CREATE TABLE Sura ( id INTEGER NULL AUTO_INCREMENT DEFAULT NULL, sura_id INTEGER NOT NULL, sura VARCHAR NOT NULL, PRIMARY KEY (sura_id, id) ); -- Table 'Ayahs' DROP TABLE IF EXISTS Ayahs; CREATE TABLE Ayahs ( id INTEGER NULL AUTO_INCREMENT DEFAULT NULL, ayah_id INTEGER NOT NULL, ayah VARCHAR NOT NULL, sura_id_Sura INTEGER NOT NULL, PRIMARY KEY (ayah_id, id) ); -- Table 'NameTafseer' DROP TABLE IF EXISTS NameTafseer; CREATE TABLE NameTafseer ( id INTEGER NULL AUTO_INCREMENT DEFAULT NULL, nametafseer_id INTEGER NOT NULL, nametafseer VARCHAR NOT NULL, PRIMARY KEY (id, nametafseer_id) ); -- Foreign Keys ALTER TABLE Tafseer ADD FOREIGN KEY (sura_id_Sura) REFERENCES Sura (sura_id); ALTER TABLE Tafseer ADD FOREIGN KEY (ayah_id_Ayahs) REFERENCES Ayahs (ayah_id); ALTER TABLE Tafseer ADD FOREIGN KEY (nametafseer_id_NameTafseer) REFERENCES NameTafseer (nametafseer_id); ALTER TABLE … -
How to Trigger Browser Refresh when Django Static Files Change
I'm building a Django/React app and trying to automatically refresh the page whenever static files change (e.g. webpack bundle that's generated whenever React code is updated). I've tried the following packages: python-livereload, django-livereload, and django-livereload-server. None worked. And, they don't appear to be actively maintained. Any thoughts/suggestions would be greatly appreciated. -
Application error in heroku after using amazon rds database
So I am attempting to deploy a Django application onto heroku using amazon aws for storing static and media files and amazon rds as the database. When pushing to deployment the pages that do not have a model associated with them are fine while the pages with them show an application crash with heroku. I then figured it was because I had already had objects in my database before setting up rds and s3 so I deleted my heroku postgresql database (nothing of importance was in there) but still no luck. Here is relevant code below settings.py: """ Django settings for plaid_blog project. Generated by 'django-admin startproject' using Django 2.0. For more information on this file, see https://docs.djangoproject.com/en/2.0/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/2.0/ref/settings/ """ import os # import dj_database_url # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'xxxxxxxxxxxx' # SECURITY WARNING: don't run with debug turned on in production! #DEBUG = TRUE DEBUG = False #ALLOWED_HOSTS = [] ALLOWED_HOSTS = ['127.0.0.1', '.herokuapp.com'] # Application definition … -
Unable to send Activation Email with Djoser in Django Rest Framework
am trying to send activation email when a user get registered . when post request is called the content of email is shown in console but it is not send to user email. Django setting : EMAIL_USE_TLS=True EMAIL_HOST='smtp.gmail.com' EMAIL_HOST_USER=<my_username@gmail.com> EMAIL_HOST_PASSWORD=<my_password> EMAIL_PORT=587 EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' DJOSER = { 'SET_PASSWORD_RETYPE' : True, 'LOGOUT_ON_PASSWORD_CHANGE' : True, 'PASSWORD_RESET_SHOW_EMAIL_NOT_FOUND' : True, 'PASSWORD_RESET_CONFIRM_URL':'#/password/reset/confirm/{uid}/{token}', 'ACTIVATION_URL': '#/activate/{uid}/{token}', 'SEND_ACTIVATION_EMAIL': True, 'SERIALIZERS': {}, } P.S : SMTP is enabled on gmail account using https://www.codingforentrepreneurs.com/blog/use-gmail-for-email-in-django/ Console output after post request -
fiedls E300 dan E307
class OrderItem(models.Model): order = models.ForeignKey('Order', related_name='items') product = models.ForeignKey('Product', related_name='order_items') price = models.DecimalField(max_digits=10, decimal_places=2) quantity = models.PositiveIntegerField(default=1) help message error fields E300 and fields E307 , output -
Django Upload Image in specific folder without FileField or ImageField and MEDIAROOT
My App needs to upload diferent profile images in diferen folders inside the static folder. One more thing, I'm not using models, I just want to take the picture I choose in html input file and copy to the specific folder. Here is my folder tree. Where I want to save the uploaded image is in MYPROJECTFOLDER/static/profile// that's where I don't want to use MEDIA_ROOT, becouse in media root I can't create a specific folder to each user. (I don't know if this is correct, if there is a way to create a specific folder to each user in the /media/ folder without using ImageField or FileField, please tell me). Here is my folder tree: MYPROJECTFOLDER | |------myproject | |------ __init__.py | |------ settings.py | |------ urls.py | |------ wsgi.py | |------myapp | |------ __init__.py | |------ admin.py | |------ apps.py | |------ forms.py | |------ models.py | |------ tests.py | |------ urls.py | |------ views.py | |------static | |-------css | |----- bootstrap.css | |----- mystyles.css | |-------fonts | |-------images | |-------js | |----- myscripts.js | |-------profile | |------folder_user1 | |------ uploadedpicture.jpg #Here is where I want to upload | |------folder_user2 | |------folder_user3 | |-------resources | |------templates | |-------myapp | … -
Dockerized Django can't connect to MySQL
Using this tutorial https://semaphoreci.com/community/tutorials/dockerizing-a-python-django-web-application, I'm dockering my Django application in a VirtualBox using docker-machine. Everything has gone splendidly until I go to my browser and my application says that it's having issues with MySQL. Then i found this documentation for dockerizing an instance of mysql https://github.com/mysql/mysql-docker which I followed, creating the image in the same development VirtualBox that I created. The error I was originally getting was Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' My Django DATABASES looked like this DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'db_name', 'USER': 'root', 'HOST': 'localhost', 'PORT': '' } } I then changed the host to 127.0.0.1 and even tried specifying the port as 3306 and I got a new error which was (2003, "Can't connect to MySQL server on '127.0.0.1' (111)") I also went in to MySQL workbench and changed the connection of my Local instance to be 127.0.0.1:3306 and that hasn't helped. The commands that I'm running are eval "$(docker-image env development)" ---> supposedly does THESE things: export DOCKER_TLS_VERIFY="1" export DOCKER_HOST="tcp://123.456.78.910:1112" export DOCKER_CERT_PATH="/Users/me/.docker/machine/machines/development" export DOCKER_MACHINE_NAME="development" Then, now that i'm in my virtualbox, I run: docker run -it -p 8000:8000 <docker image name> ---> forwards exposed port 8000 to port … -
How to hide the next parameter appearing to the url in Django?
When I am starting my Django project from the login page the url is showing like this: http://127.0.0.1:8000/login/?next=/ But what i want only this: http://127.0.0.1:8000/login What is the way to hide this next parameter appearing to the url? I have set login url and login redirect urls to the settings.py: settings.py LOGIN_URL = '/login/' LOGIN_REDIRECT_URL = '/' urls.py urlpatterns = [ url(r'^$',views.index,name='home'), url(r'login/$',views.userLogin,name='login'), ] -
apache2.2 django use python3/5
I want to run django with apache2.2 and python 3.6, after making changes in wsgy.py and virtuahost still running python 2.6 Apache/2.2.34 (Unix) DAV/2 mod_wsgi/3.2 Python/2.6.9 configured -- resuming normal operations Here wsgi.py import os, sys sys.path.append('/home/app/myapp/sivale') sys.path.append('/home/app/myvenv/lib/python3.6/site-packages') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings") from django.core.wsgi import get_wsgi_application application = get_wsgi_application() And here ServerName nuevo.sivale.mx Alias /static /home/app/myapp/static <Directory /home/app/myapp/static> Allow from all </Directory> <Directory /home/app/myapp/myapp> <Files wsgi.py> Order deny,allow Allow from all </Files> </Directory> WSGIDaemonProcess sivale python-path=/home/app/myapp:/home/app/myvenv/lib/python3.6/site-packages WSGIProcessGroup sivale WSGIScriptAlias / /home/app/myapp/myapp/wsgi.py WSGISocketPrefix /var/run/wsgi -
How to include model to another in django
I have this database in mongodb picture:"http://placehold.it/150x150" name:"Gushkool" email:"leilaware@gushkool.com" city:"Rabat" location:Object type:"Point" coordinates:Array 0:-6.81134 1:33.95564 I want create models like this database and this is my shot: class location(Document): type = fields.StringField() coordinates = fields.StringField() class products(Document): picture = fields.StringField() name = fields.StringField() email = fields.StringField() city = fields.StringField() location = ReferenceField(location) -
GeoDjango GDALException - OGR failure
After installing GeoDjango, I wanted to create a 'Location' object in the admin panel which uses an address and a point on a map. After submitting the form, I get an error like so... GDALException at /admin/maps/location/add/ OGR failure. I have tried looking at similar questions, like here, but none of the solutions have worked. Additionally, searching for 'unable to load PROJ.4 library' (first traceback line) didn't come with any success. Any help would be appreciated! - Let me know if I should update this question with my settings.py or other relevant files. Full traceback: GDAL_ERROR 6: Unable to load PROJ.4 library (libproj.dylib), creation of OGRCoordinateTransformation failed. Internal Server Error: /admin/maps/location/add/ Traceback (most recent call last): File "/Library/Python/2.7/site-packages/django/core/handlers/exception.py", line 41, in inner response = get_response(request) File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/Library/Python/2.7/site-packages/django/contrib/admin/options.py", line 551, in wrapper return self.admin_site.admin_view(view)(*args, **kwargs) File "/Library/Python/2.7/site-packages/django/utils/decorators.py", line 149, in _wrapped_view response = view_func(request, *args, **kwargs) File "/Library/Python/2.7/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func response = view_func(request, *args, **kwargs) File "/Library/Python/2.7/site-packages/django/contrib/admin/sites.py", line 224, in inner return view(request, *args, **kwargs) File "/Library/Python/2.7/site-packages/django/contrib/admin/options.py", line 1508, in add_view return self.changeform_view(request, None, form_url, extra_context) File "/Library/Python/2.7/site-packages/django/utils/decorators.py", … -
Python Spyne XML GET (not POST)
I am creating a simple Web Service using Spyne, the client (which I don't control) send a GET to verify that SSL is up and working. The Spyne service I created responds with an error, saying only POSTS are supported. Any ideas on how I can make it respond to a simple get on the same path? Example of the code (using Django, but that shouldn't make a difference): views.py: class QWCService(ServiceBase): @rpc(Unicode, Unicode, _returns=Array(Unicode)) def authenticate(ctx, strUserName, strPassword): print "authenticate" return ["auth","success"] app = Application([QWCService], 'my.namespace.com', in_protocol=Soap11(validator='lxml'), out_protocol=Soap11(), ) app_service = csrf_exempt(DjangoApplication(app)) urls.py: urlpatterns = [ url(r'^admin/', admin.site.urls), url('^qwc', app.views.app_service, name="root"), ] The only way I can figure out how to get around this is to flip the URL to a blank page, then flip it back after the check for SSL is done. Error from Spyne: Soap11env:Client.RequestNotAllowed You must issue a POST request with the Content-Type header properly set. -
Django on cPanel using 'Setup Python App' does not working
I have configured cPanel as below: And created a django project in below path: /home/my_username/virtualenv/mysite/2.7/bin/ This is my passenger_wsgi.py config: import os import sys cwd = os.getcwd() sys.path.append(cwd) sys.path.append(cwd + '/mysite') INTERP = os.path.expanduser("~/.virtualenv/mysite/3.6/bin/python3.6") if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv) sys.path.insert(0, os.path.dirname(__file__)) sys.path.insert(0,'$HOME/.virtualenvs/mysite/3.6/bin') sys.path.insert(0,'$HOME/.virtualenvs/mysite/3.6/lib/python3.6/site-packages/django') sys.path.insert(0,'$HOME/.virtualenvs/mysite/3.6/lib/python3.6/site-packages') os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' from django.core.wsgi import get_wsgi_application application = get_wsgi_application() but I getting this error: We're sorry, but something went wrong. The issue has been logged for investigation. Please try again later. I would appreciate any help! Thanks. -
How to use Django-postman and ajax-selects?
I am trying to use django-postman for user-user messaging and ajax-selects for auto completion but i am not able to do it despite going through it's documentation. I am using django inbuilt User model for signups. I want to use this model for autocompletion in recipients field of django-postman But still there is no autocomplete in my create message's recipient field. Please forgive indentation error if any, this is my settings.py AJAX_LOOKUP_CHANNELS = { 'user' : {'model':'auth.User', 'search_field':'username'}, } POSTMAN_AUTO_MODERATE_AS=True POSTMAN_DISALLOW_ANONYMOUS=True POSTMAN_DISALLOW_COPIES_ON_REPLY=True POSTMAN_AUTOCOMPLETER_APP = { 'name': 'ajax_select', # default is 'ajax_select' 'field': 'AutoCompleteField', # default is 'AutoCompleteField' 'arg_name': 'channel', # default is 'channel' 'arg_default': 'user', # no default, mandatory to enable the feature} thi is my forms.py from django-postman class WriteForm(BaseWriteForm): """The form for an authenticated user, to compose a message.""" # specify help_text only to avoid the possible default 'Enter text to #search.' of ajax_select v1.2.5 recipients = CommaSeparatedUserField(label=(_("Recipients"), _("Recipient")), help_text='') class Meta(BaseWriteForm.Meta): fields = ('recipients', 'subject', 'body') #recipients = AutoCompleteSelectField('recipients') this is my lookup.py file under django-postman app from ajax_select import register, LookupChannel from django.contrib.auth.models import User class TagsLookup(LookupChannel): model = User def get_query(self, q, request): return self.model.objects.filter(username__icontains=q).order_by('username'[:50] from my project's urls.py from ajax_select import urls as ajax_select_urls … -
Django : How can I fix this when adding facebook login to django app using social-auth?
I am using django to create a web app and add facebook login in the homepage. But whenever I run click on the facebook login link, I get the following error. Can anyone tell me where the error is and how I can fix it ? -
Django : Digital Ocean Spaces/AWS S3, how to create image using django_storages
I am trying to user django_storages package for storing images on AWS S3 or Digital Ocean spaces. When I use normal image upload using a form, the image is successfully getting uploaded to the server. But When I try to create an image manually and then write it to S3 or Digital Ocean Space buckets, the image is not getting created properly. Following is the code which I have run on Shell and tried alot: from PIL import Image, ImageDraw, ImageFont img = Image.new('RGB', (500,500), (255,255,255)) d = ImageDraw.Draw(img) d.text((10,10), "Hello", font=ImageFont.truetype("tahomabd"), fill='BLACK') d.text((10,60), "World", font=ImageFont.truetype("tahomabd"), fill='BLACK') from django.core.files.storage import default_storage as storage JPEG_PATH = "pathtofile.jpeg" storage.exists(JPEG_PATH) storage.delete(JPEG_PATH) JPEG_STORAGE = storage.open(JPEG_PATH, "w") JPEG_STORAGE.write(img) JPEG_STORAGE.close() The above code creates a .JPEG file on the storage location but it is some default file which does not make any sense. Please suggest what is issue with the code. -
my app that i included in installed_apps is not included when i deploy my django to heroku
this is the error in my deployed site every time i open it Environment: Request Method: GET Request URL: http://skinproject.herokuapp.com/ Django Version: 1.9 Python Version: 2.7.13 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] Traceback: File "/app/.heroku/miniconda/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 134. resolver_match = resolver.resolve(request.path_info) File "/app/.heroku/miniconda/lib/python2.7/site-packages/django/core/urlresolvers.py" in resolve 374. for pattern in self.url_patterns: File "/app/.heroku/miniconda/lib/python2.7/site-packages/django/utils/functional.py" in __get__ 33. res = instance.__dict__[self.name] = self.func(instance) File "/app/.heroku/miniconda/lib/python2.7/site-packages/django/core/urlresolvers.py" in url_patterns 417. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/app/.heroku/miniconda/lib/python2.7/site-packages/django/utils/functional.py" in __get__ 33. res = instance.__dict__[self.name] = self.func(instance) File "/app/.heroku/miniconda/lib/python2.7/site-packages/django/core/urlresolvers.py" in urlconf_module 410. return import_module(self.urlconf_name) File "/app/.heroku/miniconda/lib/python2.7/importlib/__init__.py" in import_module 37. __import__(name) File "/app/skindisease/urls.py" in <module> 4. from .views import ( File "/app/skindisease/views.py" in <module> 16. from .forms import PostForm File "/app/skindisease/forms.py" in <module> 4. from .models import skindisease File "/app/skindisease/models.py" in <module> 14. class skindisease(models.Model): File "/app/.heroku/miniconda/lib/python2.7/site-packages/django/db/models/base.py" in __new__ 103. "application was loaded. " % (module, name)) Exception Type: RuntimeError at / Exception Value: Model class skindisease.models.skindisease doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. in the Installed Applications: part i can't see the app that i created in django which is … -
using Django crispy forms, how do you shrink the text box for a TextField?
The text boxes that crispy forms lay out for TextField columns are too tall for my app, they are taking up too much screen space. The user can make them taller if desired by dragging the bottom frame line, but the minimum size is too tall. I would like the default height to be 4 rows or so. I tried some ideas I got off related posts, but nothing worked -- the text boxes were still the same height and too tall. Guidance would be appreciated. -
Resolve a list in Django queryset value_list
I'm doing a CSV export of a queryset. For this I dynamically receive the fields by a form and I pass them to the queryset through the filter values_list directly as a list but it launches AttributeError -> 'list' object has no attribute 'split' -
My data base list is not getting displayed if I use forums. Can any one spot the error (must be a silly mistake since I am a rookie)?
I am learning Django, and I have certain entries on the data base that just won't show up. This is my detail (template name) file: {%load staticfiles%} <img src = '{%static album.album_logo%}' alt = 'IMAGE'/> <h1>{{album.album_title}}</h1> <h2>{{album.artist}}</h2> {% if error_message %} <p><strong>{{error_message}}</strong>></p> {% endif %} <form action="{%url 'music:favorite' album.id%}" method = 'post'> {%csrf_token%} {% for songs in album.song_set.all %} <input type = 'radio' id = 'song{{ forloop.counter}}' name = 'song' value = '{{song.id}}'> <label for="song{{ forloop.counter}}"> {{Song.song_title}} {% if song.is_favorite %} <img src = 'C:/Users/my dell/Desktop/project/main/trending/static/logos/dis.png' height="1"> {% endif %} </label><br /> {% endfor %} <input type="submit" value = 'favorite'> </form> It does not display the content b/w the form tags. I am positive the error must be in this file but if you don't see any, I'll edit and provide the views and urls file as well. Help would be appreciated. -
python Django - Convert SQL Query to ORM Query(Subquery)
SELECT *, (SELECT sum(amount) FROM history WHERE history_id IN (SELECT history_id FROM web_cargroup WHERE group_id = a.group_id) AND type = 1) as sum FROM web_car a; It is very difficult to convert the above query to orm 1. orm annotate is automatically created by group by. 2. It is difficult to put a subquery in the 'in' condition please help.