Complete newbie here, trying to set up Django to work with PostgreSQL. I’m using mac osx 10.6.8. I have also installed PostgreSQL 9.3 When I run pip install psycopg2 in terminal I get the following error I’ve seen a number of posts on this how-to-install-psycopg2-with-pip-on-python pg-config-executable-not-found but I have no clue how to find the bin folder location containing pg_config.
Tag: django
Building ‘limitless’ menu trees with Django
I have a model: And want to build a template which contains menu with limitless parent-child relations for each entry, where parent id’s of the “first-level” elements is 0. And as a result to build any html menu trees I want. Answer Don’t re-invent the wheel; use a dedicated Django extension for building tree-structures. There are several packages available that
In PyCharm, how to navigate to the top of the file?
I’m new to PyCharm and haven’t been able to figure out what I’m sure is a very simple thing — what’s the key stroke to go to the top of the current file? (Bonus question — is there a way to scroll to the top of the current file without moving the cursor there also, a la the Home key
Calling a view from a management command
So I have added a command to manage.py in my django app that basically takes the results from a view and emails them out to specific users. This command will run on a cron schedule – basically this is done as an automated, emailed report. I’ve figured out how to add in the command but I want to call the
How to find uid of existing python email object
I have been reading through this document. Most of the document is based on finding an email’s uid. From the article: I’m working with a django app called django-mailbox (http://django-mailbox.readthedocs.org/en/latest/index.html) the purpose of which is to consume emails. The app creates a “Message” model that looks like: using the python “email” library I can select a record from a django
Django 1.6 No Category matches the given query
I am newbie in django .. and i dont understand what is reason this 404 error I have Page not found (404) when i try go to link No Category matches the given query. code: models.py: views.py: urls.py Answer Most likely, you don’t have category object with slug that you are specifying in the url. Due to this, the line
Django Rest Framework File Upload
I am using Django Rest Framework and AngularJs to upload a file. My view file looks like this: As the last line of post method should return all the data, I have several questions: how to check if there is anything in request.FILES? how to serialize file field? how should I use parser? Answer Use the FileUploadParser, it’s all in
Nginx is throwing an 403 Forbidden on Static Files
I have a django app, python 2.7 with gunicorn and nginx. Nginx is throwing a 403 Forbidden Error, if I try to view anything in my static folder @: nginx config(/etc/nginx/sites-enabled/myapp) contains: error.log contains: access.log contains I tried just viewing say a .css file in /static/ and it throws an error like this in source: Answer It appears the user
Django REST Framework serializer field required=false
from the documentation: read_only Set this to True to ensure that the field is used when serializing a representation, but is not used when updating an instance during deserialization. Defaults to False required Normally an error will be raised if a field is not supplied during deserialization. Set to false if this field is not required to be present during
Django REST Framework – Separate permissions per methods
I am writing an API using Django REST Framework and I am wondering if can specify permissions per method when using class based views. Reading the documentation I see that is quite easy to do if you are writing function based views, just using the @permission_classes decorator over the function of the views you want to protect with permissions. However,