Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Graphene Django: Creating a mutation with list of users to create a chat room
I'm trying to create this mutation using graphene-django for this class. I have three models: Chat, Message, and User. How would I create a new chat by linking the users by their usernames as a mutation? # Models in models.py class BaseUser(models.Model): username = models.CharField(max_length=128, unique=True) customizable_name = models.CharField(max_length=128) class Chat(models.Model): users = models.ManyToManyField(BaseUser) name = models.CharField(max_length=128, blank=True) last_message = models.DateTimeField(auto_now=True) image = models.ImageField(upload_to="uploads/chat/room", blank=True, null=True) class Message(models.Model): chat_fk = models.ForeignKey(Chat, on_delete=models.CASCADE, related_name="chat") user_fk = models.ForeignKey(BaseUser, on_delete=models.CASCADE, related_name="sending_user") text = models.CharField(max_length=500, blank=True) created_time = models.DateTimeField(auto_now_add=True) Type in schema.py class BaseUserType(DjangoObjectType): class Meta: model = models.BaseUser fields = ['id','username', 'customizable_name','created_on'] class ChatType(DjangoObjectType): class Meta: model = models.Chat fields = ['id', 'users', 'name', 'last_message', 'image'] Mutation in schema.py class CreateChat(graphene.Mutation): name = graphene.String() users = graphene.List(graphene.String) image = graphene.String() class Arguments: name = graphene.String() users = graphene.List(graphene.String) image = graphene.String() chat = graphene.Field(ChatType) def mutate(root, info, name, users, image): #user = [] #for user in models.BaseUser.objects.all(): # models.BaseUser.objects.filter(username__in) chat = Chat(name = name, users = users, image = image) chat.save() return CreateLocation( id = chat.id, name = chat.name, users = chat.users, image = chat.image, ) GraphQL on GraphiQL mutation createChat { createChat(name: "Chat", users: ["user1", "user2"], image: "Image"){ name users image } … -
Selectable list of users in Django?
models.py class EmployeeReportRequestForm(forms.Form): EMPLOYEECHOICE = [] employees = User.objects.filter(group_name='rep') for employee in employees: EMPLOYEECHOICE.append([employee.get_username(), employee.get_full_name()]) employee_choice = forms.CharField(max_length=50, widget=forms.Select(choices=EMPLOYEECHOICE)) start_date = forms.DateField(widget=forms.SelectDateWidget()) end_date = forms.DateField(widget=forms.SelectDateWidget()) Trying make a form that allows someone to make a selection from a list of users in a particular group, I figured this would work, but it is not. The most info I'm able to get error wise is "django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet." I'm assuming my issue is trying to query the User database from within a Model and that I need to run the lines of code that generate the EMPLOYEECHOICE list in a view and then somehow pass that to the Model? Or just define the widget to be used in the View? -
How to fix error 'str' object has no attribute 'relative_url'
I am trying to pass some wagtail contexts to the search page of a django project. The post title appears but the image, description and other parameters do not appear in the search template. How do I pass these contexts to the search template? This is the search.view.py code from django.shortcuts import render from wagtail.core.models import Page from wagtail.search.models import Query from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator from news.models import NewsPage, NewsCategory def search(request): posts = NewsPage.objects.live().public() categories = NewsCategory.objects.all() # Search search_query = request.GET.get('q', None) if search_query: search_results = NewsPage.objects.live().search(search_query) # Log the query so Wagtail can suggest promoted results Query.get(search_query).add_hit() reversenews = list(reversed(search_results)) # Pagination paginator = Paginator(reversenews, 16) #show 10 articles per page page = request.GET.get('page') try: search_results = paginator.page(page) except PageNotAnInteger: search_results = paginator.page(1) except EmptyPage: search_results = paginator.page(paginator.num_pages) else: search_results = NewsPage.objects.none() # Render template return render(request, 'search/search.html', { 'search_query': search_query, 'search_results': search_results, 'recent_posts' : posts, 'categories' : categories }) this is the search template search.html {% extends "news/news_index_page.html" %} {% load static wagtailcore_tags %} {% load wagtailembeds_tags %} {% load wagtailcore_tags %} {% load static wagtailuserbar %} {% load wagtailimages_tags %} {%load static%} {% load wagtailcore_tags %} {% load wagtailroutablepage_tags %} {% block content … -
Making changes on code doesn't reflect on django webapp
I'm trying to edit my code on my django but somethings really weird is happening and i don't know what's happening. making me crazy af. my chart code is inside static folder under js/chart1.js then on my django template, i have <script type="text/javascript" src="{% static 'js/chart1.js' %}"></script> now i edited the chart1.js but it wont reflect. i tried deleting staticfolder, restarting server, even deleting chart1.js under js directory just as long as <script type="text/javascript" src="{% static 'js/chart1.js' %}"></script> is there, the chart still there even tho chart1.js dont exists anymore. i dont know where the hell is django getting its data for my graph. can someone tell me whats happening? thanks! -
making gjango DeleteView generic?
I am using the django DeleteView class to delete different entries. The only thing that differs from call to call is the model attribute. It there anyway to have only one call for delete for different models? My sugggestion is something along these lines but I don't know how to implement it. Any suggestions? views.py: class Delete(DeleteView): template_name='kammem/delete.html' success_url=reverse_lazy('forl') model=super().get_context_data() def get_context_data(self,**kwargs): mod=self.kwargs['model'] if mod=='forening': model=forening elif mod=='person' return model urls.py: path('delete/<int:pk>/<str:model>',Delete.as_view(),name='delete'), -
django-crontab fails to run in background
I have setup a script that fetches offline Access Points from a Wireless Controller and saves data to DB. I am using django-crontab which runs well with the manage.py script. However, the cron job fails to execute in background. Would appreciate any guide. Thanks enter image description here -
How to implement user daily progress tracking in Django?
I'm building a web app that allows user's to write stories and track their word-count progress. I've got a working processor implemented and the ability to grab the word-count, but how do I track this word-count progress on the backend? I imagine if I were able to somehow save the user's daily word-count change and total word-count neatly in the database, I wouldn't have much trouble filtering it and then displaying it. My issue is how do you save something like this in the database? What if the user doesn't log in for a number of days and I don't run any view to add to my database? I still want those day's recorded as 0s. Any help would be greatly appreciated. Using PostgreSQL if that is relevant. -
How to share project to Github via PyCharm such that it does not include .gitignore files
I cannot figure out how to share my PyCharm project with Github so that it does not include .gitignore files. I have read solutions from other posts, and tried them, and the problem persists. What I've tried: Deleting the repository from Github Removing path to previously existing Github repo in PyCharm version control settings git remote remove origin git rm -r --cached . git add . installed ignore Then, sharing with Github... Yet it is still including files listed in .gitignore. What am I doing wrong? -
django code 400, message Bad request version ('î\x9el\x00$\x13\x01\x13\x03\x13\x02À+À/̨̩À,À0À')
I was trying to implement 'Securing Django Admin login with OTP', however I can't login into the admin panel now. I removed the app from everywhere but still doesn't work. Any solution for this? [05/Feb/2021 21:39:49] code 400, message Bad request version ('î\x9el\x00$\x13\x01\x13\x03\x13\x02À+À/̨̩À,À0À') [05/Feb/2021 21:39:49] You're accessing the development server over HTTPS, but it only supports HTTP. -
How to get Simple JWT to work for all users in a django project (Not just super user)?
I've been using Simple JWT when making a project involving Django REST backend and React JS frontend. My authentication was going well until I realized that I am only getting a token when the user is a Super User in the Django app. Any other user account simply results in {"detail":"No active account found with the given credentials"} In some form another, when I try it via logging in from React, on my token/obtain page in Django, and in a curl script through command prompt. The user is labelled as active within Django admin Is there a setting I am missing? Here are my current JWT settings in settings.py: SIMPLE_JWT = { 'ACCESS_TOKEN_LIFETIME': timedelta(minutes=10), 'REFRESH_TOKEN_LIFETIME': timedelta(days=14), 'ROTATE_REFRESH_TOKENS': True, 'BLACKLIST_AFTER_ROTATION': True, 'ALGORITHM': 'HS256', 'SIGNING_KEY': SECRET_KEY, 'VERIFYING_KEY': None, 'AUTH_HEADER_TYPES': ('JWT',), 'USER_ID_FIELD': 'id', 'USER_ID_CLAIM': 'user_id', 'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken',), 'TOKEN_TYPE_CLAIM': 'token_type', } -
Looping through a list of attirubutes from Django
Basically, I've learned this far that coding something the right way means you shouldn't have to copy and paste a lot.. At least from what I've read. I basically need to assign my Django model points based on a boolean statement. If True add points otherwise dont add points. The point values will change but for now I have them set as 1. I can either copy/paste as many of these are I have to record scores for or I can see if there's an easier way, so ultimately thats my question, is there an easier way? scores_bool = { 'spc': 1, 'medical': 1, 'photo_id': 1, 'presolo_test': 1, 'presolo_checkout': 1, 'endorsement_solo': 1, 'solo': 1, 'dual_xc': 1, 'inst_training': 1, 'dual_night': 1, 'tol_tower': 1, 'solo_xc': 1, 'solo_xc_150': 1, 'checkride_prep': 1, } if ppl.spc: ppl.points += scores_bool['spc'] if ppl.medical: ppl.points += scores_bool['medical'] if ppl.photo_id: ppl.points += scores_bool['photo_id'] if ppl.presolo_test: ppl.points += scores_bool['pre_solo_test'] So basically each ppl attribute has a True False statement, if true add the points to it...etc Ideally I would loop through the scores_bool.keys() and say something like: for i in scores_bool.keys(): if ppl.i: ppl.points += scores_bool[i] Thankyou! -
In Django how to convert an uploaded pdf file to an image file and save to the corresponding column in database?
I am creating an HTML template to show the cover of a pdf file(first page or user can choose one). I want Django to create the cover image automatically without extra upload. The pdf file is uploaded using Django Modelform. Here is the structure of my code models.py class Pdffile(models.Model): pdf = models.FileField(upload_to='pdfdirectory/') filename = models.CharField(max_length=20) pagenumforcover = models.IntegerField() coverpage = models.FileField(upload_to='coverdirectory/') form.py class PdffileForm(ModelForm): class Meta: model = Pdffile fields = ( 'pdf', 'filename', 'pagenumforcover', ) views.py def upload(request): if request.method == 'POST': form = PdffileForm(request.POST, request.FILES) if form.is_valid(): form.save() return redirect('pdffilelist') else: form = PdffileForm() return render(request, "uploadform.html", {'form': form}) def pdfcover(request, pk): thispdf = get_object_or_404(Pdffile, pk=pk) return render(request, 'pdfcover.html', {'thispdf': thispdf}) In the 'pdfcover.html', I want to use the Django template language so I can render different HTML for different uploaded pdf files. That's why I want to save the image file to the same column as the pdf file. I am new to Python, new to Django, and obviously new to stack overflow. I have tried pdf2image and PyPDF2 and I believe they all could work however I just cannot find the right code. If you guys enlighten me I will be thankful. -
Views/ forms / models. Can someone help me in it?
I tryed to add validation to ContactModel, by doing Forms.py but I went too far away with it and now dont know to fix it. Can someone help ? def addContact(request): form = ContactForm() if request.method == 'POST': form = ContactForm(request.POST) if form.is_valid(): # form = Contact( # full_name = request.POST ('fullname'), # relationship = request.POST ('relationship'), # email = request.POST ('email'), # phone_number = request.POST ('phone-number'), # address = request.POST ('address'), # ) form.save() return redirect('/contact') context = {'form': form} return render(request, 'contact/new.html', context) def contactProfile(request,pk): contact = Contact.objects.get(id=pk) return render(request, 'contact/contact-profile.html', {'contact': contact}) In my opinion in Views I have big mess.. When I fill up all fields data isn't sending to database. forms.py: from django.forms import ModelForm from .models import Contact class ContactForm(ModelForm): class Meta: model = Contact fields = '__all__' models.py: from django.db import models # Create your models here. class Contact(models.Model): full_name = models.CharField(max_length=500) relationship = models.CharField(max_length=50) email = models.EmailField(max_length=254) phone_number =models.CharField(max_length=20) address = models.CharField(max_length=100) def __str__(self): return self.full_name -
How can i write expression in Django 3+?
It is an old version, how to rewrite it to new requirements? url(r'^reset/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$', -
Django middleware doesn't working template
I implemented Django middleware for dynamic logo, site title, etc. It is working very slowly. example. When I updated my site title, it was not updated instantly. But when I server restarted It is working. this is my code class AppBasicInfo(): def __init__(self, get_response): self.site = SiteInfo.objects.first() if SiteInfo.objects.first() else "Not Implemented" self.get_response = get_response def __call__(self, request, *args, **kwargs): request.site = self.site response = self.get_response(request) return response settings file MIDDLEWARE = [ 'blog.middleware.AppBasicInfo', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'debug_toolbar.middleware.DebugToolbarMiddleware', 'blog.middleware.AppMenu', 'blog.middleware.SocialIcon', 'blog.middleware.DynamicYear', ] and I call middleware variable as my template like {{request.site.site_title}} -
Successfully deployed Django to Heroku but received application error
My application works fine on Django local server. It deployed successfully to Heroku as well. But when I go to the website, it says application error. I see a bunch of H10 and H14 error codes. I've tried updating the Procfile without the initial space. I've tried deleting and re-adding the requirements.txt file. Maybe it's something with the static files? One SO solution said delete a bunch of things from requirement.txt file that you don't need - as that worked for them. I just don't which ones to delete. I can't add my Heroku logs --tail - SO thinks recognizes it as spam. If needed, I can email it to you. Please see below: Procfile web:gunicorn myquiz.wsgi requirements.txt asgiref==3.3.1 click==7.1.2 dj-database-url==0.5.0 Django==3.1.6 django-cors-headers==3.7.0 django-heroku==0.3.1 django-nested-admin==3.3.3 djangorestframework==3.12.2 Flask==1.1.2 gunicorn==20.0.4 itsdangerous==1.1.0 Jinja2==2.11.3 MarkupSafe==1.1.1 psycopg2==2.7.7 python-decouple==3.4 python-monkey-business==1.0.0 pytz==2021.1 six==1.15.0 sqlparse==0.4.1 Werkzeug==1.0.1 whitenoise==5.2.0 Settings.py import os import django_heroku import dj_database_url from decouple import config # 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/3.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '' # SECURITY WARNING: don't run with debug turned on in production! DEBUG … -
Google analytics for Django app only shows root domain instead of page titles
I've got my first Django app in production and would like to setup Google Analytics to see pageviews/timespent/etc by page title for the order flow. I've added the GA javascript to the of my base.html template with the hope that it would track each page with page title. However, when I look at Google Analytics, I only see page views by my root domain 'mysite.com', and I cannot get get page views by '/app/pagetitle1', '/app/pagetitle2', '/app/pagetitle3', etc. 'app' is the Django app that the root domain gets redirected to 'mysite.com/app'. I'm assuming that Google Analytics would show entire path after root domain, if it were to work. It seems like there is probably something simple I've overlooked, and would appreciate any advice. Here's the GA tag I put in base.html right after per GA instructions: <!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=XXX"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'XXX'); </script> Each template extends base.html as follows: {% extends "base.html" %} {% block content %} <section class="container container-interior"> etc - rest of <body> -
Issue with updating a dictionary in for loop (not unique)
I have an issue with populating a dictionary from the database. It overwrites or merges values that from my logic should be unique to the given country. country_dict = {'Netherlands': [{'Games': {}, 'Bikes': {}, 'Paint': {}}], 'Belgium': [{'Games': {}, 'Bikes': {}, 'Paint': {}}]} for country, value in country_dict.items(): for key in value: for category in key: for channel in channel_list: if channel in channels: aggr = item_obj.filter( order_fk__order_call_fk__ship_country=country, product__parent__product_category__product_category=category, order_fk__order_call_fk__channel=channel).aggregate(Sum('retail_price')) if aggr['retail_price__sum'] != None: key[category] = {channel: round(aggr['retail_price__sum'], 2)} which gives me if i print out line for line, exactly what i want see: Netherlands Games {'retail_price__sum': None} {} Bikes {'retail_price__sum': Decimal('30.1000000000000')} {'Channel #3': Decimal('30.10')} Paint {'retail_price__sum': Decimal('56.7000000000000')} {'Channel #1': Decimal('56.70')} Belgium Games {'retail_price__sum': None} {} Bikes {'retail_price__sum': Decimal('39.7000000000000')} {'Channel #1': Decimal('39.70')} Paint {'retail_price__sum': Decimal('13.9000000000000')} {'Channel #2': Decimal('13.90')} But when I print the final dictionary it overwrites the unique Netherlands values... { "Netherlands":[ { "Games":{ }, "Bikes":{ "channel #1": "Decimal(""39.70"")" }, "Sprays":{ "channel #2": "Decimal(""13.90"")" } } ], "Belgium":[ { "Games":{ }, "Bikes":{ "channel #1": "Decimal(""39.70"")" }, "Paint":{ "channel #2": "Decimal(""13.90"")" } } ] } if I use update() instead of = if aggr['retail_price__sum'] != None: key[category].update({channel.title+str(country): round(aggr['retail_price__sum'], 2)}) it merges the two together like this: { "Netherlands":[ { "Games":{ … -
Django not showing text after extending
I am learning Django and I was extending two html files. After extending I am getting the color that I wanted but no text. Reference the examples below... base.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Hello</title> </head> <body bgcolor="red"> {% block content %} {% endblock %} </body> </html> home.html {% extends 'base.html' %} {% block conent %} <h1>Hello {{name}}!!!!!!!</h1> {% endblock %} views.py from django.shortcuts import render from django.http import HttpResponse # Create your views here. def home(request): return render(request, 'home.html', {'name': 'Bob'}) Before base.html Before base.html After base.html After base.html -
Matching query does not exist. DRF
Okay I have been at this for a while and cannot figure it out. Whenever I make a new job post I get the following error jobs.models.Positions.DoesNotExist: Positions matching query does not exist. Business Model: from django.db import models from django_google_maps import fields as map_fields from django.conf import settings User = settings.AUTH_USER_MODEL Company = settings.COMPANY_USER_MODEL class Business(models.Model): owner = models.ForeignKey(User, on_delete=models.CASCADE) business = models.CharField(max_length=50, unique=True) address = map_fields.AddressField(max_length=200, null=True) geolocation = map_fields.GeoLocationField(max_length=100, null=True) about = models.TextField(max_length=1000, null=True) def __str__(self): return self.business Job Model: from django.db import models from django_google_maps import fields as map_fields import uuid as uuid_lib from django.conf import settings User = settings.AUTH_USER_MODEL class Positions(models.Model): position = models.CharField(max_length=100) def __str__(self): return self.position class Job(models.Model): employer = models.ForeignKey(User, on_delete=models.CASCADE) business = models.ForeignKey('business.Business', related_name='jobs', on_delete=models.CASCADE) position = models.ForeignKey(Positions, on_delete=models.CASCADE) address = map_fields.AddressField(max_length=200, null=True) geolocation = map_fields.GeoLocationField(max_length=100, null=True) uuid = models.UUIDField(db_index=True, default=uuid_lib.uuid4, editable=False) job_detail = models.TextField() # TODO: set length full_time = models.BooleanField(default=False) part_time = models.BooleanField(default=False) date_posted = models.DateTimeField(auto_now_add=True) def __str__(self): return self.address Job Serializer: from rest_framework import serializers, fields from .models import Job, Type, Positions def get_business_model(): return django_apps.get_model(settings.BUSINESS_MODEL, require_ready=False) Business = get_business_model() # Position Serializer class PositionSerializer(serializers.ModelSerializer): class Meta: model = Positions fields = "__all__" class JobSerializer(serializers.ModelSerializer): date_posted = serializers.DateTimeField(read_only=True, … -
I am getting Internal server error when my app is deployed on heroku
I am still a beginner and some errors which appear I do not understand it, thank you for helping me pleaseenter code here i get this error when i run heroku logs --apps myapp 2021-02-04T19:02:55.752352+00:00 app[web.1]: url = self.url(context) 2021-02-04T19:02:55.752352+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/templatetags/static.py", line 103, in url 2021-02-04T19:02:55.752352+00:00 app[web.1]: return self.handle_simple(path) 2021-02-04T19:02:55.752353+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/templatetags/static.py", line 118, in handle_simple 2021-02-04T19:02:55.752353+00:00 app[web.1]: return staticfiles_storage.url(path) 2021-02-04T19:02:55.752353+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 147, in url 2021-02-04T19:02:55.752354+00:00 app[web.1]: return self._url(self.stored_name, name, force) 2021-02-04T19:02:55.752354+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 126, in _url 2021-02-04T19:02:55.752354+00:00 app[web.1]: hashed_name = hashed_name_func(*args) 2021-02-04T19:02:55.752354+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 417, in stored_name 2021-02-04T19:02:55.752355+00:00 app[web.1]: raise ValueError("Missing staticfiles manifest entry for '%s'" % clean_name) 2021-02-04T19:02:55.752355+00:00 app[web.1]: ValueError: Missing staticfiles manifest entry for 'store/css/stylee.css' 2021-02-04T19:02:55.752355+00:00 app[web.1]: 2021-02-04T19:02:55.752356+00:00 app[web.1]: During handling of the above exception, another exception occurred: 2021-02-04T19:02:55.752356+00:00 app[web.1]: 2021-02-04T19:02:55.752356+00:00 app[web.1]: Traceback (most recent call last): 2021-02-04T19:02:55.752357+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 47, in inner 2021-02-04T19:02:55.752357+00:00 app[web.1]: response = get_response(request) 2021-02-04T19:02:55.752357+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/deprecation.py", line 114, in call 2021-02-04T19:02:55.752358+00:00 app[web.1]: response = response or self.get_response(request) 2021-02-04T19:02:55.752358+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 49, in inner 2021-02-04T19:02:55.752358+00:00 app[web.1]: response = response_for_exception(request, exc) 2021-02-04T19:02:55.752358+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 103, in response_for_exception 2021-02-04T19:02:55.752359+00:00 app[web.1]: response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info()) 2021-02-04T19:02:55.752363+00:00 app[web.1]: File … -
Django-Virtual env
scripts folder is not available in my virtual environment folder.Any one please help me How to activate virtual env ? I did following commonds :- pip3 install virtualenv virtualenv bg cd bg cd scripts shailesh@shailesh:~/Blog/bg$ cd scripts bash: cd: scripts: No such file or directory shailesh@shailesh:~/Blog/bg$ -
Django TabularInline radio button
I have a situation where a person can be added with multiple addresses. But the user should select only which one is the default address. I'm thinking to add a radio button but not sure how. Current UI -
ModuleNotFoundError: No module named '____' - Django
Im trying to import my Django models into another script so I can create extra functions for importing csv data etc. Everything ive seen online suggests I run these lines before importing my models: import os, sys os.environ.setdefault("DJANGO_SETTINGS_MODULE", "projdir.proj.settings") from django.core.wsgi import get_wsgi_application application = get_wsgi_application() from project.app.models import Model But this returns: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked ModuleNotFoundError: No module named 'app' Ive also got init.py files in both the project folder and app folder?? Can someone explain what's going on? Thanks -
Users become unvisible in users category when i remove the thick from the boolean field button
When i remove the thick from the 'Referans Kodu Doğrulaması', users become unvisible in admin panel. I've tried almost every parameters of BooleanField but i couldn't change the situation. I thought former migrations result it altough i changed it too but nothing changed. Admin Panel models.py admin.py