Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Update value of a column in postgres into lower case
I have a table name service_table which have some fields. A field have days name like Sunday, Monday, Tuesday etc.. I want to change all the column value in postgres database table into lower case. For Instance 'Sunday' update as 'sunday' I am written a query update service_table set days=lower(days); but it shows Hint: No function matches the given name and argument types. You might need to add explicit type casts. Note: This table has some foreign key. -
DJANGO: How to hide model defaul in django admin?
When I started project , Django provided for me an app has tables default, such as Email addresses, Email confirmations in ACCOUNTS... But I don't want those appear in my admin page . Anybody can help me to hide it in admin page. Thank you. -
Radio button using react/redux
I am trying to create front end for Django polls app using react/redux. I have a component Single which displays the selected question. Single.js class Single extends Component { handleSubmit(e) { e.preventDefault(); console.log('Form Submitted in single'); } render() { const { questions, choices, actions } = this.props; console.log('this.props', this.props, 'question', questions); const { id } = this.props.params; const i = questions.findIndex(x => x.id == id); const question_obj = questions[i]; console.log('question_obj', question_obj); return ( < div className = 'ListSection' > < h2 > Poll Your Choice < /h2> { question_obj.question_text } < form ref = 'choiceForm' onSubmit = { this.handleSubmit.bind(this) } > { choices.map((choice, i) => <Choice {...this.props} key = {i} i = {i} choice = {choice}/>)}</form> </div> ); } } function mapState(state) { return { questions: state.ques, choices: state.choices }; } function mapDispatch(dispatch) { return { actions: bindActionCreators(QuesActions, dispatch) }; } export default connect(mapState, mapDispatch)(Single); How can I display choices along with radio buttons and handle submit? I am using a separate component Choice for each choice which means I can't send the selected radio button data from child (Choice) to parent (Single) component. -
No module named GoogleOAuth2django.contrib.auth.backends
I am trying to add google authentication to a django app using python-social-auth. Earlier i was able to add linkedin auth so i thought it would be similar. I followed the steps given on the official document. But when i click login with google this error comes. Traceback Environment: Request Method: GET Request URL: http://127.0.0.1:8000/login/google-outh2/ Django Version: 1.8.4 Python Version: 2.7.10 Installed Applications: ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'social.apps.django_app.default', 'django_social_app', 'django_countries') Installed Middleware: ('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', 'django.middleware.security.SecurityMiddleware') Traceback: File "/Users/ravinkohli/env_socialauth/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 132. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/Users/ravinkohli/env_socialauth/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 57. response = view_func(request, *args, **kwargs) File "/Users/ravinkohli/env_socialauth/lib/python2.7/site-packages/social/apps/django_app/utils.py" in wrapper 48. backend, uri) File "/Users/ravinkohli/env_socialauth/lib/python2.7/site-packages/social/apps/django_app/utils.py" in load_backend 29. Backend = get_backend(BACKENDS, name) File "/Users/ravinkohli/env_socialauth/lib/python2.7/site-packages/social/backends/utils.py" in get_backend 51. load_backends(backends, force_load=True) File "/Users/ravinkohli/env_socialauth/lib/python2.7/site-packages/social/backends/utils.py" in load_backends 33. backend = module_member(auth_backend) File "/Users/ravinkohli/env_socialauth/lib/python2.7/site-packages/social/utils.py" in module_member 56. module = import_module(mod) File "/Users/ravinkohli/env_socialauth/lib/python2.7/site-packages/social/utils.py" in import_module 50. __import__(name) Exception Type: ImportError at /login/google-outh2/ Exception Value: No module named GoogleOAuth2django.contrib.auth.backends //login.html {% if user and not user.is_anonymous %} <a>Hello, {{ user.get_full_name }}!</a> <br> <a href="/logout/">Logout</a> {% else %} <a href="{% url 'social:begin' backend='linkedin-oauth2' %}">Login with Linkedin</a> <a href="{% url 'social:begin' backend='google-outh2' %}">Login with Google</a> {% endif %} //settings.py AUTHENTICATION_BACKENDS = ( … -
will database pull whole table at once or one row by one row after using model.objects.all().iterator() in django?
I know django will return the model object one by one after using iterator() on queryset to save memory. In database side, will the database pull the data one row by one row or still pull the whole table at once just like model.objects.all(). -
How to get textbox value in views.py django
base.html <form action="#" method="POST" role="form"> <div class="tab-content"> <div class="tab-pane active" role="tabpanel" id="step1"> <div class="mobile-grids"> <div class="mobile-left text-center"> <img src="{% static 'images/mobile.png' %}" alt="" /> </div> <div class="mobile-right"> <h4>Enter your mobile number</h4> <!-- <label>+91</label><input type="text" name="mobile_number" class="mobile-text" value="asdfasd" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = '';}" required=""> --> <label>+91</label><input type="text" name="mobile_number" class="mobile-text" value="" > </div> </div> <ul class="list-inline pull-right"> <li><button type="button" class="mob-btn btn btn-primary next-step">Next</button></li> </ul> </div> <div class="tab-pane" role="tabpanel" id="step2"> <div class="mobile-grids"> <div class="mobile-left text-center"> <img src="{% static 'images/mobile.png' %}" alt="" /> </div> <div class="mobile-right "> <h4>Prepaid or Postpaid?</h4> <div class="radio-btns"> <div class="swit"> <div class="check_box"> <img src="{% static 'images/card.png' %}" alt="" /> <div class="clearfix"></div> <div class="radio"> <label> <input type="radio" name="radio" checked=""><i></i>Prepaid </label> </div> </div> <div class="check_box"> <img src="{% static 'images/card.png' %}" alt="" /> <div class="clearfix"></div> <div class="radio"> <label> <input type="radio" name="radio"><i></i>Postpaid </label> </div> </div> </div> </div> </div> </div> <ul class="list-inline pull-right"> <li><button type="button" class="mob-btn btn btn-default prev-step">Previous</button></li> <li><button type="button" class="mob-btn btn btn-primary next-step">Next</button></li> </ul> </div> <div class="tab-pane" role="tabpanel" id="step3"> <div class="mobile-grids"> <div class="mobile-left text-center"> <img src="{% static 'images/mobile.png' %}" alt="" /> </div> <div class="mobile-right "> <h4>Which operator?</h4> <ul class="rchge-icons"> <li><a href="#">Airtel</a></li> <li><a href="#">Aircel</a></li> <li><a href="#">Bsnl</a></li> <li><a href="#">Idea</a></li> <li><a href="#">Vodafone</a></li> <li><a href="#">Reliance</a></li> <li><a href="#">Uninor</a></li> </ul> <div class="section_room"> <select id="country" … -
Waiting for receive channel in django channels
Suppose if I'm sending a message to a client, I'm expecting an immediate response back from the client. Whenever I send a message to client using Group.send() I need to receive a response from the client. But Group.send() can be called from any function and the response might be receiving in different consumer function. How can I make sure that whatever the client is sending back should be my return value in the function where I'm calling Group.send() Sample Code for consumers.py: def ws_receive(message): msg = message.content['text'] return msg def send_to_client(param1, param2, param3): Group.send({ "text" : json.dumps({ "First" : param1, "Second" : param2, }) }) So once the message reaches at the client side, the client will send a response back to the server which will be received by the ws_receive(message) function through the websocket.receive channel which is defined in the urls.py file, channel_patterns = [ route("websocket.receive", ws_receive), ... ] Is there a way so that I can receive the client response in the same send_to_client variable in some variables. So that my function looks like this, def send_to_client(...): Group.send(...) response_message = #response message from client -
Getting a "bound method" error with my login form
So my register form works fine, it successfully creates a new user. However my login form cannot log a user in. So when I log in with username/password entered correctly, and print(form.non_field_errors) in my view, I get this error: <bound method BaseForm.non_field_errors of <UserLoginForm bound=True, valid=False, fields=(username;password)>> Can somebody tell me what this means? So the login form is invalid but not sure why. And when I print(form.errors) in the same view I get this error: <ul class="errorlist"><li>username<ul class="errorlist"><li>A user with that username already exists.</li></ul></li></ul> Also, keep in mind these register and login functions don't have a seperate url, they are all on on the homepage (accessible via javascript onclick, to prevent page refresh). Here's my code: views.py def boxes_view(request): form = UserRegistrationForm(request.POST or None) form_login = UserLoginForm(request.POST or None) if request.user.is_authenticated(): print('LOGGED IN') context = { 'form': form, 'form_login': form_login } return render(request, 'polls.html', context) def register(request): form = UserRegistrationForm(request.POST or None) if form.is_valid(): username = form.cleaned_data['username'] password = form.cleaned_data['password'] email = form.cleaned_data['email'] user = User.objects.create_user(username=username, password=password, email=email) user.save() return redirect('/') else: print(form.errors) print(form.non_field_errors) form = UserRegistrationForm() return redirect('/') def user_login(request): form_login = UserLoginForm(request.POST or None) if form_login.is_valid(): username = form_login.cleaned_data['username'] password = form_login.cleaned_data['password'] user = authenticate(username=username, password=password) login(request, … -
How to write python script queries which is call to django for get the data in server
I want to write all types of complex queries, for example : If someone wants information "Fruit" is "Guava" in "Pune District" then they will get data for guava in pune district. If someone wants information "Fruit" is "Guava" in "Girnare Taluka" then they will get data for guava in girnare taluka. If someone wants information for "Fruit" is "Guava" and "Banana" then they will get all data only for this two fruits, like wise Data : { "Fruit": "Pomegranate", "District": "Nasik", "Taluka": "Nasik", "Revenue circle": "Nasik", "Sum Insured": 28000, "Area": 1200, "Farmer": 183 } { "Fruit": "Pomegranate", "District": "Jalna", "Taluka": "Jalna", "Revenue circle": "Jalna", "Sum Insured": 28000, "Area": 120, "Farmer": 13 } { "Fruit": "Guava", "District": "Pune", "Taluka": "Haveli", "Revenue circle": "Uralikanchan", "Sum Insured": 50000, "Area": 10, "Farmer": 100 } { "Fruit": "Guava", "District": "Nasik", "Taluka": "Girnare", "Revenue circle": "Girnare", "Sum Insured": 50000, "Area": 75, "Farmer": 90 } { "Fruit": "Banana", "District": "Nanded", "Taluka": "Nandurbar", "Revenue circle": "NandedBK", "Sum Insured": 5000, "Area": 2260, "Farmer": 342 } { "Fruit": "Banana", "District": "Jalgaon", "Taluka": "Bhadgaon", "Revenue circle": "Bhadgaon", "Sum Insured": 5000, "Area": 220, "Farmer": 265 } I know that there are so many combination for run this query. for example : … -
How to add current user into a field in django model serializer
I am developing an application in django-rest-framework. Following is my serializer: class MySerializer(serializers.HyperlinkedModelSerializer): class Meta: model = My fields = ('user','title','description') The problem is that when I run it, it asks for the user to be selected like this: I want that whichever user is logged in, he should be added to user field automatically. In django website development, I used to do it using request.user but how do I do it in django rest framework? -
Advice: How would you implement chartjs in a django blog
I have a django project I use as a blog and I want to implement chartjs with it for charting stuff. These would be charts that are entered as a blog writer so I can't be pulling the stats from the db (at least I can't think of a way to go about it that way) I have come up with three possible approaches that I can see but I can't tell which one is best. put a model method on a blog post that would substitute chart script from markdown like syntax, something like... [chart_js] type: line labels: 1, 2, 3, 4, 5 data: 6, 7, 8, 9, 10 data2: 11, 12, 13, 14, 15 [/chart_js] That would be scanning the post everytime the view is rendered with a regex looking for the chart_js tags. make a chart app and then put a <script> tag in each post with a chart that sends an ajax request to my endpoint with data. that way in the post I would write something like... <script> $.get('char-endpoint', {type: 'line', data: {}, labels: []}) .done(function(data){ //put it in the canvas )}; </script> I could do #1 but instead of scanning it on my backend … -
Proper way of using url patterns
I've created a form which by submit uploads an item to the database. The problem is that if I press f5 it'll run it again, because of the URL is now different. I have these two url patterns urlpatterns = [ url(r'(?i)^$', views.index, name='index'), url(r'^createItem/$', views.createItem, name='createItem') ] and my view looks like this def CMS(request): form = itemCreateForm() context = { 'form' : form, 'message' : 'Content Manage Site' } return render(request, 'CMS.html', context) def createItem(request): f = itemCreateForm(request.POST) if f.is_valid(): f.save() pass form = itemCreateForm() context = { 'form' : form, 'message' : 'ItemCreated!' } return render(request, 'CMS.html', context) the CMS.html {% if message %} {{ message }} {% endif %} <div class='newItemFields'> <form action="{% url 'kar:createItem' %}" method="POST"> {% csrf_token %} {{ form.as_p }} <input type="submit"> </form> </div> my form class itemCreateForm(ModelForm): class Meta: model = item fields = ['name', 'type', 'price'] I start at homepage/CMS/ and fill in the form and press submit, and view function createItem runs and creates and saves the object in the database. And sends the user to homepage/CMS/createItem. And now everytime the user press f5 the createItem function will run again and insert another object into the database with the same … -
I want to iterate items and return it based on foreign key relationship, but only one item is returning
I have a StudentAttendance model that is a foreign key to Student. I have defined a template to return the days for a particular student and the status. And like wise for Grade, showing all the subject for that student and displaying the grade scored. The code below is only returning one item. For instance, a student attendance was recorded for Monday, Tuesday and Wednesday and only Monday is being returned but I want all to be displayed. def studentdetails(request, id): instance = Student.objects.get(id=id) registration = Registration.objects.filter(id=id) gradedetails = Grade.objects.filter(id=id) studentattendance = StudentAttendance.objects.filter(id=id) context = { "instance": instance, "registration": registration, "gradedetails": gradedetails, "studentattendance": studentattendance, } return render(request, "studentdetails.html", context) Here's the template: <div> {% for day in studentattendance %} {{ day.day }}: {{ day.status }} {% endfor %} </div> -
How do I save m2m field session from a form to another?
I'm doing a multi step form where everything is saved at the end. In my models I have a m2m checkbox field and I'm using django Sessions to grab the forms datas to show it on the final step. The issue is that the m2m field (checkboxes) is not saved when I submit the final form. Here is my views file : views.py def step1(request): initial={'name': request.session.get('name', None), 'checkbox': request.session.get('checkbox', (False,))} #cookies form = FormOneForm(request.POST or None, initial=initial) if request.method == 'POST': if form.is_valid(): request.session['name'] = form.cleaned_data['name'] request.session['checkbox'] = form.cleaned_data.get('checkbox') return HttpResponseRedirect(reverse('step2')) return render(request, 'step1.html', {'form': form}) def step2(request): form = FormTwoForm(request.POST or None) if request.method == 'POST': if form.is_valid(): formtwo = form.save(commit=False) formone2 = FormOne.objects.create(checkbox=request.session.get('checkbox')) #error is here formone = FormOne.objects.create(name=request.session['name']) formtwo.owner = formone formtwo.save() formone2.save_m2m() return HttpResponseRedirect(reverse('step3')) return render(request, 'step2.html', {'form': form}) models.py class Font(models.Model): font_name = models.CharField(max_length=100) font_family = models.CharField(max_length=100) font_link = models.CharField(max_length=100) ... class FormOne(models.Model): name = models.CharField(max_length=40) checkbox = models.ManyToManyField(Font, blank=True) ... class FormTwo(models.Model): owner = models.ForeignKey(FormOne) name = models.CharField(max_length=40) ... this code gives me this error : 'checkbox' is an invalid keyword argument for this function How can I achieve what I am trying to realise ? -
Execute a function on termination of Jquery.on()
I have a bit of javascript code that I'm having trouble understanding. The code takes an input value from a button that was pressed, and passes this information to a django view to filter the models that are displayed on the screen. This aspect of the code is fully functional. After the page reload, depending on the filter that was applied, I would like to make it seem as if the correct button is pressed by giving it a different class so that is visually distinct. However, I have not been able to figure out how to execute this task after the ajax has completely terminated. I've been doing some research into javascript call backs, but I still haven't figured out how to resolve this issue. $('.gender-filter-button').on('click', function(event) { event.preventDefault(); var element = $(this); //button that was clicked //Case where button has not yet been clicked if ( element.hasClass(btn_unclicked) ) { filters = {'gender_filter': element.val()} } //Case where button has been previously clicked else { filters = {'gender_filter': 'noFilter'} } $.ajax({ url : 'search/ajax_filter/', type: 'GET', data: filters, }).done(function (data) { if (data.success) { window.location.href = data.url; } }); }); -
Fast filter on related fields in django
I have 2 models in my django project. ModelA(models.Model): id = models.AutoField(primary_key=True) field1 = ... ~ fieldN = ... ModelB(models.Model): id = models.AutoField(primary_key=True) a = models.ForeignKey(A, on_delete=models.CASCADE) field1 = ... ~ fieldN = ... Here I have one-to-mane relation A->B. Table A has around 30 different fields and 10.000+ rows and table B has around 15 and 10.000.000+ rows. I need to filter firstly by the several ModelA fields and then for each of the filtered ModelA row/object get related ModelB objects and filter them by several fields. After that I need to serialize them in JSON where all ModelB packed in one field as array. Is it possible to perform this around the 1-3 second? If yes, what is the best approach? I use PostgreSQL. -
“settings.DATABASES is improperly configured” error performing syncdb with django 1.9
I start a tutorial for Django 1.9 and I want to use Mongoengine for my database .. when I tried migrate the DB "CMD: python manage.py migrate" I had this error [ raise ImproperlyConfigured("settings.DATABASES is improperly configured. " django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details. ] My code : settings.py import os from mongoengine import * # 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/1.9/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '3x80*9(7bdeg^lps-go9a8(@x_vmk#5vj66d9l0t3js(vknq(i' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'mongoengine', 'TestApp' ] MIDDLEWARE_CLASSES = [ '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', ] ROOT_URLCONF = 'testMongoDB.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')] , 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'testMongoDB.wsgi.application' # Database # https://docs.djangoproject.com/en/1.9/ref/settings/#databases connect('myDB',username="NOUH",password="123456" ) SESSION_ENGINE = 'mongoengine.django.sessions' SESSION_SERIALIZER = 'mongoengine.django.sessions.BSONSerializer' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.dummy' } } # Password … -
Error message of Django SessionWizardView
I'm working on a SessionWizardView. One of its steps is for uploading a file. If user clicks the Next button without uploading a file, it shows an error message. However, the error message doesn't disappear if a file is then uploaded. To debug this issue, I inserted some print statements in post() function of the wizard and init() function of the form class for that step, but nothing was printed as I upload the file while the error message showing. Could anyone please suggest? Thanks! -
Django model field isn't showing up correctly in the django admin
The PtoHistory Model: class PtoHistory(models.Model): LEAVE_CHOICES = ( (True, 'PTO'), #is chargeable? (False, 'Jury Duty'), #is chargeable? (False, 'Voting'), #is chargeable? (False, 'Military Leave'), #is chargeable? (False, 'Bereavement'), #is chargeable? (True, 'Emergency'), #is chargeable? ) user = models.ForeignKey(User, on_delete=models.CASCADE) leave_start_date = models.DateTimeField(auto_now=False, auto_now_add=False) leave_end_date = models.DateTimeField(auto_now=False, auto_now_add=False) leave_type = models.BooleanField(choices=LEAVE_CHOICES) def __str__(self): return self.user.username The problem: Whenever I change the "leave_type" inside of the django admin, for example, to "Emergency" it will show up as "PTO" in the django admin because they are both True but PTO comes up first in the tuple so it shows "PTO" in the django admin. The same thing happens for all of the options that are False. If "Military Leave" is selected and saved, when viewed in the django admin it shows up as "Jury Duty" because "Jury Duty" is the first false in the tuple. dango admin pic What I want to happen: If the user chooses "Bereavement", I want "Bereavement" to show up in the django admin as the choice that was selected and I want it to correspond to a False value meaning that it won't count against the employee's PTO hours. I hope my desired output is understood and I … -
Django crashes on the second form POST while creating a matplotlib.pyplot image from a pandas object
My Django program crashes with the following error: Segmentation fault (core dumped) ... which is some kind of C error. My difficulty is debugging the stack - I don't know where to chase the problem. analysis is a pandas DataFrame object Here's the offending code that loads in Django in the index View: def index(request): d = {'a': [0,1,2,3], 'b': [-2,5,3,0] } analysis = pd.DataFrame(data=d) myImage = image(analysis) context = {'form': form, 'myImage': myImage } def image(analysis): print('if this is the second POST, you will crash on running the next line') image = analysis.plot(x='a', y='b') buf = io.BytesIO() plt.savefig(buf, format='png') buf.seek(0) image = base64.b64encode(buf.read()) return image The form POST runs perfectly the first time. The second POST is the problem. I can reproduce the error by doing the following: User visits / User fills in the form, selects his file and pushes submit Form directs to / (the same URL) and loads with an image after analyzing a uploaded file User changes the form fields, uploads a file (new or different doesn't matter), then pushes submit for the second time The program crashes on running image = analysis.plot(x='Indicator Value', y='Mean Period Return') in image() I made a little test program … -
How do you port a Node application to Django
Currently, I have a Node application that runs on Heroku using a Procfile with the contents web: node index.js. I would like to port this to Django. How do I do this? I have been unable to find any relevant resources online. -
How can i filter time in django?
How can i filter time in django, if time start from 00:00 - 10:00 data wich will show is data which have time 'pagi', if 10:01 - 18:00 is 'siang', and if data 18:01 - 23:59 is 'malam'. I have code like this. This is template.html: <!DOCTYPE html> <head> <html> <meta charset="utf-8"> <title>This Is Latihan</title> </head> <body> <div id="form"> <form action="{% url insert %}" method="POST">{% csrf_token %} Nama Maskapai : <input type="text" name="airline" id="airline" value="{{ airline }}"></input> </br> Waktu Berangkat : <input type="text" name="time" id="time" value="{{ time }}"></input> </br> <input type="submit" name="save" value="save"> </form> </div> <table id="table" border="1"> <tr> <th align="center" width=30px>No.</th> <th align="center" width=150px>Maskapai</th> <th align="center" width=70px>Waktu</th> <th align="center" width=230px colspan="4">Action</th> </tr> {% for i in maskapai %} <tr> <td align="center" width=30px>{{ forloop.counter }}</td> <td width=150px>{{ i.airline }}</td> <td width=70px> {{ i.time }}</td> <form action="{% url action %}" method="POST">{% csrf_token %} <td width=230px colspan="4"> <input type="hidden" name="index" value= "{{ forloop.counter0 }}" /> <input type="hidden" name="time" value= "{{ i.time }}" /> <input type="submit" name="delete" value="delete"> <input type="submit" name="up" value="up"> <input type="submit" name="down" value="down"> </td> </form> </tr> {% endfor %} </table> <form action="{% url filter %}" method="POST">{% csrf_token %} <select name="maskap"> <option value="all">-Pilih Maskapai-</option> {% for pil in pilihan %} <option … -
How do I get Django and apache to work together with virtualenv?
Ok sorry I know this question is similar to another but when I tried the other answer did not seem to work for me. Apache2.2:ImportError: No module named site. So I am trying to get django/virtualenv/apache working together. Any help is greatly appreciated!! Here are the error logs. Part one of apache error logs Part tow of apache error logs Here is my apache conf file <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html ServerName tracker.com <Directory /var/www/html/drish/drish> <Files wsgi.py> Require all granted </Files> order allow,deny allow from all </Directory> WSGIDaemonProcess project python-path=/var/www/html/drish/:python-home=/var/www/html/virtenv WSGIScriptAlias / /var/www/html/drish/drish/wsgi.py Alias /static /var/www/html/drish/drish </VirtualHost> I have not changed anything in the wsgi.conf file all I did was enable it. Though I did see some options in there but not sure what any of them do. Here is the WSGI.py file that was created by django which I have also changed nothing. import os from django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "drish.settings") application = get_wsgi_application() Again thanks for any help. -
Can't find local files after pushing new git branch
From the top of the directory and master branch: Added a selection of the files in the directory to git : `git add file1.py file2.py file3.py file4.py file5.py git status shows that all have been added successfully git commit shows that 3 files were created which makes sense because 2 were modified and 3 were new > git commit -m 'viewervalidation' [master f73f0bc] viewervalidation 5 files changed, 289 insertions(+), 6 deletions(-) create mode 100644 viewervalidation/file1.py create mode 100644 viewervalidation/file2.py create mode 100644 viewervalidation/file3.py I push to master and am rejected because of work I don't have locally > git push origin master To github.com:groupflix/data-science.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'git@github.com:xxx.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. So I decide to create a new branch called vv_exp1 and push to that: > git checkout -b 'vv_exp1' M general_scripts/data_munging/neo4j_query.py D general_scripts/data_munging/remove_bad_users.py … -
Ping google about paginated sitemap django
I have sitemap.xml with 150k rows. I'm using pagination, so have sitemap.xml?p=1, sitemap.xml?p=2 etc. How should I tell Google about these pages, using Django? Or google will discover sitemap.xml and all pages with p param? Thank you.