Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Python: How can I change the title of a page in Django based on variable?
I am working with a Django app which uses the same template for different 'pages'--basically, the page can either be a "Create Entry" page or an "Edit Entry" page. The page changes based on the following parameters: {% if props.data.id %} Edit {% else %} Create {% endif %} The logic being: if an id exists for this entry, the page will display as a Edit page. Otherwise, the page will display as a Create page. I would like the title of the page to change depending on the same parameters. So the two versions of the page should be: Create Entry Edit Entry Here's the code I'm currently trying: {% if props.data.id %} {% with action='Edit' %} {% endwith %} {% else %} {% with action='Create' %} {% endwith %} {% endif %} {% block title %} {{ action }} Entry {% endblock %} I haven't gotten this to work yet. Am I on the right track? I was using 'with' since that seems to be the recommended way to set variables in Django, but I'm wondering if there's a better way to do this. -
Web-sockets & Django
This is a table of posts, I want to update status(red highlighted) when ever a user comment on a post. I used websockets to show realtime comments on the page(if tab is open comment will show without page refresh). But if user post a comment I want to update this status in real time. enter image description here Kindly help me if you know anything. -
Refresh webpage on database change (Django)
First of all, I am a beginner in web dev so excuse me if this seems vague/weird. I am making a werewolf-based browser multiplayer game, and I would like to refresh the datas on front-end whenever an user makes a move. I was thinking about a channel layer, but I would like to know if this was possible to do without, I don't need users to communicate between each other, simply a connection client/server where the webpage/content refresh whenever a data is being added/removed/modified within the database. And channel layers seems complicated for a beginner such as me Thanks for the help ! -
CSS showing on local computer, but not on Heroku (Python, Django)
I have built a website using both bootstrap styling, and also a stylesheet for other changes I wish to make along the way. I have it displaying a certain way on my local machine, but I can't get it refelected on my site. Is there something that I need to add to my settings.py file to know that it should read the static css file? Here is my html file for this one: {% load static %} <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <title> Insure Need </title> {% bootstrap_css %} {% bootstrap_javascript jquery='full' %} <link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}"> </head> <body> <nav class="navbar navbar-expand-md navbar-light bg-light mb-4 border"> <a class="navbar-brand" href="{% url 'website:welcome' %}">InsureNeed</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span></button> <div class="collapse navbar-collapse" id="navbarCollapse"> <ul class="navbar-nav mr-auto"> <li class="nav-item"> <a class="nav-link" href="{% url 'website:insureNeeds' %}">InsureNeed</a> </li> <li class="nav-item"> <a class="nav-link" href="{% url 'website:learn' %}">Learn</a> </li> <li class="nav-item"> <a class="nav-link" href="{% url 'website:contact' %}">Contact</a> </li> </ul> </div> </nav> <main role="main" class="container"> <div class="pb-2 mb-2 border-bottom"> {% block page_header %}{% endblock page_header %} </div> <div> {% block content %}{% endblock content %} </div> </main> <!--{% include 'website/footer.html' %}--> </body> … -
Dockerfile - activate Python virtualvenv - ubuntu
I am trying to create an Docker Image that contains an Apache Webserver with Django. I am using virtual environments in my production environment and I don't know how to activate it in a Dockerfile. This is my Dockerfile: FROM ubuntu/apache ARG GITLAB_USERNAME ARG GITLAB_TOKEN RUN apt-get update RUN apt-get upgrade -y RUN apt-get install -y python3 python3-pip apache2 libapache2-mod-wsgi-py3 libpq-dev git RUN pip3 install virtualenv RUN mkdir -p /var/www WORKDIR "/var/www" RUN git clone https://${GITLAB_USERNAME}:${GITLAB_TOKEN}@gitlab.com/g5362/gnsave.git RUN mv gnsave/Netto\ umgeschrieben/ ./GNSave RUN rm -r gnsave WORKDIR "/GNSave/" RUN virtualenv gnsave RUN source gnsave/bin/activate && pip install -r requirements.txt RUN a2enmod wsgi RUN chown -R www-data:www-data /var/www/GNSave RUN chmod -R u+w /var/www/GNSave RUN chmod -R 775 /var/www/GNSave/assets COPY django.conf /etc/apache2/sites-available/django.conf RUN a2dissite 000-default RUN a2ensite django RUN /etc/init.d/apache2 restart The error messae I get is: /bin/sh: 1: source: not found My question is if I should split the django and apache into two dockers and compose them or if there is a workaround for activation venvs in my Dockerfile. Thanks in advance! -
pymongo fails with error 'sys' is not defined
I have a Django app that queries mongodb. requirements.txt: # other dependencies pymongo==4.1.0 View: client = pymongo.MongoClient("mongodb+srv://*****@****.mongodb.net/test_db?retryWrites=true&w=majority") When this line is executed, the Django server throws the following error: venv/lib/python3.9/site-packages/pymongo/uri_parser.py, line 467, in parse_uri Exception: name 'sys' is not defined How do I fix this error? I'm on Python3.9 and latest Django. -
Is a good pratice use React as OAuth authorization screen?
I has my application using react to frontend and django as backend server, I need to implement an oauth provider in my backend. I want to know if is a good pratice use react to show the authorization screen of the oauth. Should I use django rest framework to provide oauth endpoints, to list the scopes with react forwarding the client secret to the API? -
Difference between two multiple arrays by the index in PYTHON
Hi guys i just start to programming and im trying to get this right. A = [['1','Jack','33'], ['2','Maria','23'], ['3','Christian','9'] ] B = [['1','Jack','33'], ['2','Maria','23'], ['3','Christian','9'], ['4','Denis','45'] ] I want to check the array B[0] and print out just "4 Denis 45" -
How to convert class type to string python SDK
I have this code that prints information related to VM. The output is in the class type. How can I convert it to a form so that I can understand it? from azure.common.credentials import ServicePrincipalCredentials from azure.mgmt.compute import ComputeManagementClient credential = ServicePrincipalCredentials(client_id='XXXX', secret='XXXX', tenant='XXXX') compute_client = ComputeManagementClient( credential, 'XXXX') for vm in compute_client.virtual_machines.list_all(): print(vm.storage_profile) I am getting output in the form. It is showing the class type of this output <'azure.mgmt.compute.v2019_03_01.models.storage_profile_py3.StorageProfile'> -
How can I use low-level caching in Django ListView CBV?
I know how to use low-level caching in base generic view (from django.views.generic import View) CBV! but I don't know where to use low-level caching in ListView CBV in django! I mean should I use it in get_queryset() function or get_object() and so on? Please share if you have any experience and do not rate it negatively because I could not find it anywhere! -
query from multi table in django
i have 3 tables class list_c (models.Model): list_name=models.CharField(max_length=50,verbose_name="",blank=True) def __str__(self): return self.list_name class Meta: verbose_name = '' verbose_name_plural = '' class candidate (models.Model): can_name = models.CharField(max_length=60, verbose_name='') can_da2ira = models.ForeignKey(da2ira,on_delete=models.CASCADE,verbose_name='') can_list = models.ForeignKey(list_c,on_delete=models.CASCADE,verbose_name="",related_name='list') def __str__(self): return self.can_name class Meta: verbose_name = '' verbose_name_plural = '' class result (models.Model): r_can = models.ForeignKey(candidate,on_delete=models.CASCADE,verbose_name="", related_name='can') r_iktira3 = models.ForeignKey(kalam_iktira3,on_delete=models.CASCADE,verbose_name="",related_name='qalam') r_result = models.IntegerField(verbose_name="") i have Django 4 project with 3 models and view how can get this : i need to get in template table (can_name ,list_name,sum(r_result ) -
Create Quiz in Django
My needs is to create a Quiz in Django and for now i'm starting with Admin section. models.py: class Answer(models.Model): objects = None answer = models.CharField(max_length=200, null=False) answer_pic = models.ImageField(upload_to='poll', storage=fs) def __str__(self): return self.answer class Question(models.Model): objects = None question = models.CharField(max_length=200, null=False) description = models.CharField(max_length=255, null=True) question_pic = models.ImageField(upload_to='poll/', storage=fs, null=True) choices = models.ManyToManyField(Answer, related_name='QuestionsChoices') correct = models.ManyToManyField(Answer, related_name='QuestionsCorrect') mandatory = models.BooleanField(default=True) multiple = models.BooleanField(default=False) randomize = models.BooleanField(default=False) def __str__(self): return self.question class Quiz(models.Model): objects = None STATUS_CHOICES = ( (1, 'Draft'), (2, 'Public'), (3, 'Close'), ) nom = models.CharField(max_length=200, null=False) questions = models.ManyToManyField(Question, related_name='Quizs') status = models.IntegerField(choices=STATUS_CHOICES, default=1) published = models.DateTimeField() date_added = models.DateTimeField(auto_now_add=True) date_modified = models.DateTimeField(auto_now_add=True) def __str__(self): return self.nom forms.py class QuestionForm(forms.ModelForm): question = forms.CharField( widget=forms.TextInput(attrs={'size': 20, 'class': 'form-control'}), label="Question :", required=True, help_text='Intitulé de la question', ) description = forms.CharField( widget=forms.Textarea(attrs={'rows': 2, 'cols': 40, 'class': 'form-control'}), label="Description :", required=True, help_text='Description de la question (obligatoire)', ) question_pic = forms.ImageField( label="Illustration : ", widget=forms.FileInput(attrs={'class': 'form-control'}), required=False, help_text='Choisir une illustration', ) mandatory = forms.BooleanField( label="Réponse obligatoire ?", initial=False, required=False, help_text='Question obligatoire ou pas ?', ) multiple = forms.BooleanField( label="Plusieurs réponses possible ?", initial=False, required=False, help_text='Plusieurs réponses possible ?', ) randomize = forms.BooleanField( label="Affichage aléatoire des réponses ?", initial=False, … -
Is there a way to control the messages after redirect or even clear messages?
Is there a way for me to stop the other validations after the first redirect in views.py from django.contrib import messages # from django.core.exceptions import ValidationError from django.shortcuts import render, redirect def register(request): if request.method == 'POST': form = request.POST phone_number = validate_phone(request, form.get("phone_number")) username = validate_user_name(request, form.get("username")) password = validate_password(request, password1=form.get("password1"),password2=form.get("password2")) ....other_fields.... return render(request, 'registration.html',) def validate_user_name(request, username): username = username.strip() new = MyUser.objects.filter(username=username) if new.count(): messages.error(request, "User with that Username Already Exist") return redirect("pre_register") # raise ValidationError("User with that Username Already Exist", code="username_error") return username def validate_password(request, password1, password2): if password1 and password2 and password1 != password2: messages.error(request, "Passwords don't match") return redirect("pre_register") # raise ValidationError("Password don't match") return password2 ....other_validations.... in registration.html: <h3 class="register-heading">Apply as a Member</h3> {% for message in messages %} <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message.tags }} : {{message}}</li> {% endfor %} <form method="post"> <input type="text" class="form-control" placeholder="Username *" value="" required="required" name="username"/> <input type="text" minlength="10" maxlength="10" name="phone_number" class="form-control" placeholder="Your Phone *" value="" required="required"/> <input type="password" class="form-control" placeholder="Password *" value="" required="required" , name="password1"/> <input type="password" class="form-control" placeholder="Confirm Password *" value="" required="required" , name="password2"/> </form> Let's say a user enters a username that already exists, what I want is: To keep the … -
How to dynamically change name of html button using javascript as soon as page loads
Is it possible to change the words displayed on button using javascript? Im trying to change the words Day 1, Day 2, and Day 3 on the buttons to the current date and next 2 days, (Day 1-> 4/05, Day 2 -> 4/06, Day 3 -> 4/07) In my views I'm passing some queries as context #appointmentApp.views time_selector_view(request): #list of the next 2 dates day = datetime.datetime.now() dates.append(day) while (i < 3): day = day datetime.timedelta(days = 1) dates.append(day) i += 1 #3 queries for each date in the list timeslots = Timeslots.objects.filter(date_sel=dates[0].date()) timeslots2 = Timeslots.objects.filter(date_sel=dates[1].date()) timeslots3 = Timeslots.objects.filter(date_sel=dates[2].date()) #I want each time slot query to have its own tab context = { 'dates' : dates, 'time_slots1' : timeslots, 'time_slots2' : timeslots2, 'time_slots3' : timeslots3 } return render(request, appointment_template/time_selector.html, context) my html page <!-- want to change the words displayed on the buttons --> <!-- appointment_template/time_selector.html --> {% extends "base.html" %} {% block content %} <body> <!-- Is it possible to change the words displayed on the buttons, Day 1 Day 2 and Day 3 using javascript?--> <div class="time_slot_tabs"> <button class="time_slot_tab_button" onclick="openCity(event, 'Day1')" id="defaultOpen">Day 1</button> <button class="time_slot_tab_button" onclick="openCity(event, 'Day2')">Day 2</button> <button class="time_slot_tab_button" onclick="openCity(event, 'Day3')">Day 3</button> </div> <div id="Day1" class="time_slot_tab_content"> {%for … -
null value in column violetes not-null constraint in Django rest-api
I have created API called test_api and trying to send data to using POSTman In my models.py I have a model structured like this class test_API(models.Model): IDnumber = models.IntegerField(unique = True, primary_key = True, null=False, editable = False, blank=True) State = models.CharField(max_length = 256, null = True) Exlcludmethod = models.CharField(max_length=256, null=True) I migrate this to postgresql database and all values in those columns are empty. Then I used postman to send some data to API end point Getting error saying <null value in column "IDnumber" violates not-null constraint DETAIL: Failing row contains (null, CA, remove). > What is the reason for this I searched but could not find a solution why this is happening IntegrityError null value in column "name" of relation "tag" violates not-null constraint null value in column "list_name" violates not-null constraint DETAIL: -
ProgrammingError - relation "blog_app_post" does not exist LINE 1: SELECT COUNT(*) AS "__count" FROM "blog_app_post"
I have a problem with my database every time I deploy it to heroku. The code works okay on localhost but shows ProgrammingError when deployed. When ever I remove the category from the codes, it seems to work but still having another issue with the auth dashboard. Here is the view.py code class BlogView(ListView): model = Post template_name = 'blog.html' ordering = ['-post_date'] paginate_by = 10 def get_context_data(self, *args, **kwargs): genres_menu = Category.objects.all() context = super(BlogView, self).get_context_data(*args, **kwargs) context["genres_menu"] = genres_menu print(context) return context Here is the model.py code from django.db import models from django.contrib.auth.models import User from django.urls import reverse from datetime import datetime, date from ckeditor.fields import RichTextField class Category(models.Model): name = models.CharField(max_length=255) def __str__(self): return self.name def get_absolute_url(self): return reverse('blog') class Post(models.Model): title = models.CharField(max_length=255) author = models.ForeignKey(User, on_delete=models.CASCADE) category = models.ForeignKey(Category, on_delete=models.CASCADE) thumbnail = models.ImageField(null=True, blank=True, upload_to="thumb_images/blog_post") snippet = models.CharField(max_length=255, default='This is a default snippet') likes = models.ManyToManyField(User, related_name='blog_posts') def total_likes(self): return self.likes.count() def \__str_\_(self): return self.title + ' | ' + str(self.author) def get_absolute_url(self): return reverse('blog') Here is the url.py code from .views import BlogView urlpatterns = \[ path('blog/', BlogView.as_view(), name='blog'), \] Here is the template code {% if genres_menu %} <div class="widget-area"> <div class="widget-collapse-btn"> … -
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding Python runtime state: core initialized ModuleNotFound
No matter what I do I can't fix the problem. I'm having trouble deploying. I am getting error 503 Service Unavailable. Current thread 0x00007f6008afd740 (most recent call first): <no Python frame> Python path configuration: PYTHONHOME = '/home/usr/virtualenv/core/3.8' PYTHONPATH = '.:/home/usr/core/' program name = '/home/usr/virtualenv/core/3.9/bin/python' isolated = 0 environment = 1 user site = 1 import site = 1 sys._base_executable = '/home/usr/virtualenv/core/3.9/bin/python' sys.base_prefix = '/home/usr/virtualenv/core/3.8' sys.base_exec_prefix = '/home/usr/virtualenv/core/3.8' sys.platlibdir = 'lib64' sys.executable = '/home/usr/virtualenv/core/3.9/bin/python' sys.prefix = '/home/usr/virtualenv/core/3.8' sys.exec_prefix = '/home/usr/virtualenv/core/3.8' sys.path = [ '.', '/home/usr/core/', '/home/usr/virtualenv/core/3.8/lib64/python39.zip', '/home/usr/virtualenv/core/3.8/lib64/python3.9', '/home/usr/virtualenv/core/3.8/lib64/python3.9/lib-dynload', ] Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding Python runtime state: core initialized ModuleNotFoundError: No module named 'encodings' Current thread 0x00007fdbc7fe0740 (most recent call first): <no Python frame> I tried almost all the methods I came across with the Google search engine, i tried removing the PYTHONHOME environment variable, which is the most popular solution. I also tried with Linux and Windows. But I never understood the problem. I would be very happy if someone could help me with this. -
Python / Django template : dropdown menu after the third elements
I would like have a list where I can see the first three elements then if there are more elements it will be in a dropdown menu like this : MESSAGE Message 01 Message 02 Message 03 ShowMore (clickable) Message 04 .... Thi is my template : {% if messages %} <div class="collection-item"> <ul> {% for message in messages %} <li{% if message == object %} class="active"{% endif %}> <a href="{{ message.get_absolute_url }}" title="{{ message.customer_product }}" data-turbolinks="false"> <i class="material-icons state-flag {{ message.get_color }}-text">lens</i> <span class="hide-on-collapsed">{{ message }}</span> <span class="show-on-collapsed"><small>{{ message.title }}</small></span> </a> </li> {% endfor %} </ul> </div> {% endif %} -
Store and Retrieve Complex data from django session
Please I created a class in django that contains both variables and functions. import scipy.special from django.db import models class neuralNetwork(models.Model): def __init__(self,no_of_Inodes,no_of_Hnodes,no_of_Onodes,learning_rate): self.inputnodes = no_of_Inodes self.hiddennodes = no_of_Hnodes self.outputnodes = no_of_Onodes self.lr = learning_rate self.w_input_hidden = numpy.random.normal(0.0,pow(self.inputnodes,-0.5),(self.hiddennodes,self.inputnodes)) self.w_hidden_output = numpy.random.normal(0.0,pow(self.hiddennodes,-0.5),(self.outputnodes,self.hiddennodes)) self.activation_function = lambda x: scipy.special.expit(x) pass I initialized it and decided to use it in a different page using 'request.session'. I used django rest framework to serialize it. from rest_framework import serializers from .neuralclass import neuralNetwork class NeuralSerializer(serializers.ModelSerializer): class Meta: model = neuralNetwork fields = '__all__' Then I tried to store it in 'request.session' after training the class (it will contain some values I will use later in a different page). request.session["stored"] = NeuralSerializer(n,many=False).data Then this is what I did to retrieve it in a new page. A page I want to test the network. n = neuralNetwork(request.session["stored"]) But then it always return an empty value for 'n' for me. Please what can I do to allow me to save and retrieve such information from page to page -
Django OneToManyField ProfileUpdate integration with user registration
I m having problems integrating user registration form info with another form used as a profile updater Models.py class Profile(models.Model): skill_choices = (('Beginner', 'BEGINNER'), ('Intermediate', 'INTERMEDIATE'), ('Expert', 'EXPERT')) user = models.OneToOneField(User, on_delete=models.CASCADE) location = models.CharField(max_length=30, blank=True) assumed_technical_ski_level = models.CharField(max_length=30, choices=skill_choices) years_of_experience = models.IntegerField(blank=True) money_to_spend = models.IntegerField(blank=True) @receiver(post_save, sender= user) def create_user_profile(self, sender, instance, created, **kwargs): if created: Profile.objects.create(user=instance) @receiver(post_save, sender=user) def save_user_profile(self, sender, instance, **kwargs): instance.profile.save() Views.py class ProfileUpdateView(LoginRequiredMixin, TemplateView): profile_form = ProfileForm template_name = 'aplicatie2/profile-update.html' def post(self, request): post_data = request.POST or None profile_form = ProfileForm(post_data, instance = request.user.profile) if profile_form.is_valid(): profile_form.save() return HttpResponseRedirect(reverse_lazy('aplicatie2:lista')) context = self.get_context_data(profile_form = profile_form) return self.render_to_response(context) def get(self, request, *args, **kwargs): return self.post(request) Forms.py class ProfileForm(forms.ModelForm): class Meta: model = Profile fields = ('location', 'assumed_technical_ski_level', 'years_of_experience', 'money_to_spend') The registration is done using the django standard library UserCreationForm I'm getting this error : RelatedObjectDoesNotExist at /companies/questions/ User has no profile. Does someone know a solution to this ? -
How do I get my CreateAPIView to recognize the "validate' seciton of my serializer?
I'm using Django 3.2 and Django rest framework 3.12.2 and have django.contrib.auth installed. I would like to create an endpoint to create users, so I have set this up in my views ... class CreateUserView(CreateAPIView): model = User permission_classes = [ IsAuthenticated ] serializer_class = UserSerializer And I have created this serializer ... class UserSerializer(serializers.ModelSerializer): class Meta: model = User fields = ('username', 'password', 'email', 'id', 'first_name', 'last_name') def validate(self, data): errors = {} # required fields required_fields = ['username', 'password', 'email'] for field in required_fields: if not data[field]: errors[field] = 'This field is required.' if errors: raise serializers.ValidationError(errors) return data def create(self, validated_data): user = User.objects.create_user( username=validated_data['username'], password=validated_data['password'], first_name=validated_data['first_name'], last_name=validated_data['last_name'], email=validated_data['email'] ) return user Unfortunately when I submit a request withoutcertain fields (e.g. "email"), read -d '' req << EOF { "first_name": "Test 9999", "last_name": "Dave", "username": "test3@abc.com", "password": "password1" } EOF curl --header "Content-type: application/json" --header "Authorization: Token 6cbf7a80c6dd40e84861c8de143c945aef725676" --data "$req" --request POST "http://localhost:8000/users/" My validator isn't running and instead I get errors in the "create" part of my serializer ... File "/Users/davea/Documents/workspace/chicommons/maps/web/directory/serializers.py", line 453, in validate if not data[field]: KeyError: 'email' How do I structure my view such that the validator in my serializer will be recognized? -
How to translate text in an external javascript file? (Django)
I have a JavaScript file that appends elements to the body according to the user interaction. Right now in my index.html template I'm declaring global variables with the translated text: {% block main %} <script> let TRANSLATION = {% trans "my text" %} </script> {% endblock %} So after Django translates the text in my index template, my JavaScript file can take the translated text and append it using something like: element.innerHTML = TRANSLATION; I know this is a very dirty way of translating the text that JavaScript will use because some users won't need that text and in those cases I'll be wasting resources with variables that I won't be using. So the question is: What is the clean and correct way to translate text for external JavaScript files? -
how do I show the options of a radio button with widget_tweaks?
I'm using widget_tweaks, everything is displayed fine except the radio buttons, when I put this code, it displays the information as a select, and what I want is for it to look like a radio button. Is there any way that the options are show like this? models.py COUNTRIES=( ('EUA', ('EUA')), ('Canada', ('Canada')), ('Other', ('Other')), ) class Profile(models.Model): country = models.CharField(max_length=100, default=0,choices=COUNTRIES) html <label class="form-label d-block mb-3">Country :</label> <div class="custom-radio form-check form-check-inline"> {% render_field form.country class="form-check-input" type="radio" %} <label class="form-check-label" for="customRadioInline1">United States</label> </div> <div class="custom-radio form-check form-check-inline"> {% render_field form.country class="form-check-input" type="radio" %} <label class="form-check-label" for="customRadioInline2">Canada</label> </div> <div class="custom-radio form-check form-check-inline"> {% render_field form.country class="form-check-input" type="radio" %} <label class="form-check-label" for="customRadioInline2">Other</label> </div> -
I can't activate my virtual environment in PowerShell
When i try activate my virtual environment in CMD, doesn't exit any problem but in PowerShell i'm having that error: PS C:\Users\Burak\desktop\my-site\myenv\Scripts> activate.bat activate.bat : The term 'activate.bat' is not recognized as the name of a cmdlet, function, script file, or operable program. Check t he spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + activate.bat + ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (activate.bat:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundExceptionenter code here -
How to write script for dropping column from table in django
I want to write this command in script so that i can drop the required column from a table in django. $ python manage.py dbshell $ psql> ALTER TABLE <table_name> DROP column <COLUMN_NAME>; $ python manage.py syncdb need this coomand in a script form.