Tagged Questions
0
votes
1answer
9 views
Django - cant pass parameter in HttpResponseRedirect
I have read that after successfully dealing with post data, you should use HttpResponseRedirect to redirect to another page. I am building a URL shortener for learning purposes, the code from views.py ...
0
votes
1answer
33 views
object() takes no parameters
I have installed django admin and am getting object() takes no parameters error. I see the error is at debug_toolbar panel.py line 55. Am not sure how to debug it.
I have pasted the traceback.
...
1
vote
2answers
18 views
How to make Django REST Framework return a list of hyperlinks instead of all data in one list?
I'm creating a REST API in Python/Django using the popular Django REST Framework.
I stumbled upon something however.
I have an API call in the code fragment below to display all memes.
This returns ...
1
vote
1answer
20 views
Django session key based expiration
I'm using Django sessions and I want to set expiry for a particular key. In an AJAX view I'm doing the following
request.session['a'] = True
request.session.set_expiry(604800)
Does this set the ...
0
votes
2answers
18 views
How do I save the current logged in username in the CreateView submit action in Django?
I want to create a restaurant review submission page where the username of the user who is submitting the review is saved in the database table. I think I have to override the save method of the ...
0
votes
1answer
19 views
Accessing dictionary values in django template
I'm trying to access key value pairs from a dictionary in a Django template, but am facing some issues.
The dictionary looks something like this:
{datetime.datetime(2014, 10, 31, 0, 0, ...
-1
votes
1answer
17 views
Django shell won't use ipython
when I run python manage.py shell, it uses just an ordinary python not iPython.
How do I make it run iPython.
P.S. I think iPython is installed in the virtaulenv
0
votes
0answers
29 views
Clean in forms doesn't work
I am trying to make my user's username lowercase. But somehow it doesn't work. I just can't see a mistake... Why is it not working?
Model:
class UserProfile(models.Model):
# This line is ...
0
votes
1answer
18 views
How to select fields to be displayed in generic ListView class in Django?
I'm using Django (v1.7) and I'm looking for a "Django style" way to select the fields to be displayed in a generic.ListView.
Let me provide an example:
In models.py:
class Stuff(generic.models):
...
0
votes
0answers
15 views
Caching Mashape API calls in Python
How can I cache Mashape API calls. I got the code below but it does not seem to be doing the caching. Mashape is using unirest to get the API response.
def fetchMashape(url, headers):
cached = ...
0
votes
1answer
22 views
Relationships with pairs of interrelated models
Let's say I have 3 models in Django: Person, Workfield and SubWorkfield.
A person can have many workfield-s and many subWorkfield-s as well, but the subWorkfield-s must be related to their parent ...
0
votes
0answers
16 views
Django on postgresql - Partitioned table with foreign keys
I have a table of over 100,000 records and I want to improve to query times.
The table stores objects with insertion time, and 95% of the queries select objects from the previous 14 days.
At the ...
-1
votes
0answers
23 views
apple push notifications script not working suddenly
How can I test if my development ASPN certificate is working?
My python script gives the following error:
Traceback (most recent call last):
File "pushnot.py", line 15, in <module>
...
0
votes
1answer
25 views
How to store a JQuery submitted variable and reuse it at a later stage in a Python/Django project?
I have developed an application using Python2.7 and Django 1.6 which uses the below slider bar to allow a user to rate various images using a multi page SessionWizardView form. The user rating is ...
-1
votes
1answer
26 views
How do I return objects' attributes in Django?
I am working on a friendship system with Django and I am using the following model:
class Friendship(models.Model):
sender = models.ForeignKey(User, related_name='friendship_sender')
receiver = ...
0
votes
0answers
15 views
How to deploy DJango website in CPanel?
I am new to the world of website hosting, especially in CPanel platform. I have a website which is developed using Python language, which makes use of Django also. I have hosted this website in ...
0
votes
1answer
37 views
How to do complex query like this
I have the following get and get_queryset methods in my CustomersListView class:
def get(self, request, *args, **kwargs):
"""
:param request:
:param args:
:param kwargs:
:return:
...
0
votes
1answer
15 views
How to use django-paypal to update a users account balance
I'm using the standard django-paypal module found here:
https://github.com/spookylukey/django-paypal
What I am trying to achieve is a person can add funds to their account on my website without ...
0
votes
1answer
18 views
Append choices to choice list in Django models dynamically
I want to select the options from a list in my django models. But the options in the list are populated in the post_save() method.The situation is like this:
I enter some attributes in the table1 ...
0
votes
1answer
13 views
django remove value from select list when in edit template
I am using Django 1.4.6.
I want to remove the 1st item in a html select list when the form is in edit mode.
I have read I should use pop(0) to remove the 1st value of the select list, but I am ...
0
votes
1answer
14 views
Django Model OneToOneField from existing primary key
I'm working with an Account model and I want to inner join it with a Settings model without having to create an additional settings_id column in my Account model, because the PK on the Account table ...
0
votes
0answers
18 views
Django unit test failing for multiple Postgres schemas
My Postgres DB has 3 schemas: default, cedirData and webData.
For those models that are pointing to a different schema than default, I'm specifying this as follows:
class Person(models.Model):
...
0
votes
0answers
26 views
Pass arguments to multiple forms with the same request in Django
I am new in django and I have a doubt:
Is possible pass arguments to a several forms.
Scenario:
I have an html table rendered with django-tables2, in the first column I have a drop down button. One ...
0
votes
1answer
19 views
Django - How to sort a querySet.values() i.e. List of Dictionary?
I'm trying to sort a list of dictionary through the use of values() of a querySet.
I find the list of dictionaries through:
set_of_pk_values = ...
0
votes
0answers
23 views
Packaging or compiling django application
I have been developing a django application, and now i want to give to someone for testing but i want to keep the sourcecode hidden/compiled so they can't modify it, is there a way to package a django ...
0
votes
1answer
15 views
dyld: Symbol not found: _iconv_open, a conflict between git and postgres
I am trying to get postgres and git to work together in a python3.4 / django1.7 work environment on a Mac with Mavericks. My problem is simple to describe:
When I put the following line in my ...
0
votes
2answers
19 views
Django find_each (like RoR)
Is there way to use find_each in django?
According to the rails documentation:
This method is only intended to use for batch processing of large
amounts of records that wouldn’t fit in memory ...
0
votes
2answers
28 views
You are trying to add a non-nullable field 'new_field' to userprofile without a default
I know that from Django 1.7 I don't need to use South or any other migration system, so I am just using simple command python manage.py makemigrations
However, all I get is this error:
You are ...
-1
votes
0answers
24 views
Online Lab Will Not Work - Python
I am trying to do this lab for my CTM work study in college. I'm basically running these scripts to connect raspberry pi's together. However, whenever I attempt to run the said scripts I am bombarded ...
1
vote
3answers
45 views
How can I find out why an object can't be JSON serialized?
I have a very simple use case of data that I wish to serialize to JSON, but I keep getting tripped by error TypeError: <api.tests.MemberInfo object at 0x02B26210> is not JSON serializable
Here ...
1
vote
2answers
38 views
Edit two models in one form
I extended the standard User model of Django as described in the Django
documentation to add some fields.
from django.db import models
from django.contrib.auth.models import User
class ...
0
votes
0answers
11 views
Filtering resources and nested resources with Django Rest Framework
I have two models: JobCategory and Job. What I would like to do is provide an initial view of data to populate a collection of Backbone models, where only the JobCategories that have Jobs are ...
0
votes
0answers
9 views
Django syncdb return a KeyboardInterrupt when it is trying to install indexes
I'm trying to use scrapy to crawl some page and make the data crawed stored im MySQL database with django.so I create a django app,fill the models.py like following code(the code is too long so there ...
0
votes
0answers
14 views
Admin Deletes all give me mysql 1146 error
Here's the setup - Python 2.6, Django 1.4.12, Centos 6.5
When trying to delete an object from the Django Admin from the model "Entity", the error below occurs.
The Project is called App is "portal" ...
1
vote
2answers
17 views
Which timezone does Django use in DateField's auto_now_add?
How does Django write the date field when the field is marked with auto_now_add attribute?
Is it like datetime.now().date() or timezone.now().date()?
In other words, which timezone does it use to ...
-1
votes
0answers
68 views
python dicts different but when serializing they're the same data [on hold]
How is this happening? I have the following code -
data_full = dict(request.DATA)
event_details = request.DATA['event_action_details']
schedule_details = request.DATA['event_schedule_details']
...
0
votes
1answer
12 views
django - pre-set request.DATA in a variable that won't change
I have a view where I'm doing some modification on the request.DATA and then splitting into a few serializers but I still want to keep a master copy of the request.DATA. Problem is the variable I set ...
0
votes
2answers
16 views
django-tables2 ignores ManyToManyField
I have these models:
class Category(models.Model):
name = models.CharField(max_length=10)
uuid = models.CharField(max_length=36)
class Item(models.Model):
name = ...
0
votes
1answer
39 views
Django HttpResponse Internal Server Error when logged out
I have a JQuery request for JSON data in my Django app (which started in vitrualenv with uwsgi and nginx):
$.getJSON( url, function( data ) {
var obl = "/raj/?raj=" + data.id;
$.getJSON( ...
-3
votes
0answers
23 views
how to set up django to use apache on linux
Can someone point me to a document on how to perform a setup for Apache.
What modules would it be good to install ( I presume as a site package for Python)?
What should the settings.py reflect to ...
0
votes
2answers
24 views
Django sqlite3 database dump
How can i create Django sqlite3 dump file (*.sql) using terminal?
There is a fabric fabfile.py with certain dump scripts, but when i try to use fab command next massage shows up:
The program 'fab' ...
1
vote
1answer
40 views
Different users get the same search results
The point of my question is the following. I have Django form with a field, which inherits the Selet2 field:
class Select2ModelField(MyBaseSelect2ModelField, AutoModelSelect2Field):
'''
...
0
votes
1answer
24 views
NoReverseMatch in Django, but there's a names url pattern for it
I'm getting a no NoReverseMatch error in a django app I've just pulled from someone else. The exact error is
NoReverseMatch at /dataupload/
Reverse for ''upload'' with arguments '()' and keyword ...
0
votes
0answers
27 views
django.template.loader can't find template
I'm adding text content to a webapp.
When I ran the app in the local server i had no issue, but when i uploaded the template to the server it returns me this error:
Environment:
Request Method: ...
-1
votes
0answers
49 views
[[ jQuery ]] How can I send and get JSON data? [[ Django ]]
I would like to combine Django with jQuery.
models.py:
from django.db import models
class nikkeihyou(models.Model):
taishaku = models.PositiveSmallIntegerField()
kamoku = ...
0
votes
1answer
23 views
Python Django: Pass json from view to javascript in template
I am new to django.
From my findings, I tried this way, but didn't work.
<script type="text/javascript" >
var data = {{json}}
</script>
I am trying to use data table from this ...
0
votes
2answers
15 views
Django raising Type Error “profile() got an unexpected keyword argument 'user'”
I've been working with Django for a short while and today I ran into a problem that for the life of me I can't figure out. I'm trying to load the user's profile which they themselves have saved on a ...
0
votes
0answers
31 views
How to let a project subclass my app's model?
I have a reusable app that provides a model. I want projects using my app to be able to add custom fields to my app's model. The strategy I have used so far was this:
# my app's models.py
class ...
0
votes
1answer
25 views
Django Tables 2 Field Accessor backward relationship
I have this model structure. (I'm using Django 1.7)
class Event(models.Model):
publicID = models.CharField(max_length=128)
class Origin(models.Model):
publicID = ...
0
votes
0answers
13 views
Django Cascading Forms
Python 3.3.2, Django 1.6.5, Fedora 20
I've got a form in Django and I would like the options in a drop down menu to be restricted based on the selection of a previous item. I've got a model, Sport, ...