django

Python and curl question

Hello, I will be transmitting purchase info (like CC) to a bank gateway and retrieve the result by using Django thus via Python. What would be the efficient and secure way of doing this? I have read a documentation of this gateway for php, they seem to use this method: $xml= Some xml holding data of a purchase. $curl = `/usr/bin/curl ...

as3: How to upload bitmap data to server using httpRequest

Hi! I captured screenshot of my ui element, and would like to send it to server, using httpService. Currently I am doing the following: var httpService:HTTPService = new HTTPService(); httpService.method = "POST"; httpService.url = "/admin/compositions/add/"; httpService.addEventListener(ResultEvent.RESULT, onresult); var bitmapData:B...

Django: Redirect logged in users from login page

I want to setup my site so that if a user hits the /login page and they are already logged in, it will redirect them to the homepage. If they are not logged in then it will display normally. How can I do this since the login code is built into Django? ...

django set_expiry behaving strangely

Hi, I have an app on a UK based server with server time set to GMT The app should be set to Paris time so my settings include TIME_ZONE = 'Europe/Paris' I have sessions saving every request: SESSION_SAVE_EVERY_REQUEST = True For the most part I want the session time to be the default 2 weeks. However when people want to book an...

Remove and ignore all files that have an extension from a git repository

I'm working on a django project with a few other developers and we have recently realized that all the .pwc files in our app cause the commits and repository to be cluttered. Is there any way I can remove all .pwc files from all child directories in my git repository and then ignore them for any future commit? ...

How to write .htaccess if django project is in subfolder and subdomain?

The path to my django site is: staging.ninjawebsite.com/clients/project/ I want that to be treated as the base url. The django project is in the public_html/clients/project subfolder. Everything seems to be working fine but all links to say /city/ should go to staging.ninjawebsite.com/clients/project/city/ but it goes to staging.ninjaweb...

Detect mobile browser (not just iPhone) in python view

Hello there, I have a web application written in Django that has one specific page I'd like to implement a mobile version of the template (and slightly different logic) for. I'd like to be able to implement it ala this sudo code: def(myView) do some stuff if user-is-on-a-mobile-device: do some stuff return (my mobile te...

Automatically prompt to update default site domain name when running Django’s ./manage.py syncdb?

Regarding Django Sites module and manage.py syncdb The Auth module can prompt to ask for default superuser for the admin site, during .\manage.py syncdb. I would like to see similar things happen for the default site domain name. Currently it is example.com, hardcoded unless I use admin web site to change it. I want to change it during ...

Python template help

I'm using App Engine's web-app templating system (similar if not identical to django) Normally I render templates from my static directory /templates/ as follows in my main handler: dirname = os.path.dirname(__file__) template_file = os.path.join(dirname, os.path.join('templates', template_name)) output = template.render(template_f...

How can I interactively explore why a test is failing?

I have a test that is failing with: ====================================================================== FAIL: test_register_should_create_UserProfile (APP.forum.tests.test_views.UserTestCAse) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Us...

Django array or list output?

I'm pulling a set of image urls and their respective titles. I've tried creating a hash or associative array, but the data seems to overwrite so I only end up with the last item in the array. For example; thumbnail_list = [] for file in media: thumbnail_list['url'] = file.url thumbnail_list['title'] = file.title I've even tr...

How to configure database permissions for a Django app?

I'm looking for links, or an answer here, on to how to properly configure the database permissions to secure a Django app? To be clear, I'm looking specifically for material dealing with grants on the database, not permissions within the Django framework itself. ...

Django: Extends or Include?

My friend and I are having a small argument. In my current Django Project, I have created a file called menu.html which will contain a bunch of links configured and formatted into a list. Instead of manually hard-coding the menu into each page, I am currently including the menu using the following Django/Python code: {% include 'menu.ht...

django+flex: Debugging strategies

Hi! I love django, and I like flex. Django for it's cool debugging system (those yellow pages helps a lot to find bugs in my code), and flex for it possibilities. Recently I come across a problem. If I create a form in flex and then communicate with the django server, I can't see any debugging info (when the exception happens in django...

How to completely dump the data for Django-CMS

I have an instance of Django-CMS already running in a production environment. I would like to dump all the data related to the CMS (PAGES and PLUGINS) so that I may load it back into my development environment. When I do python manage.py dumpdata cms it dumps most of the data, but not all of it. None of the content for the plugins i...

Deplying Django with WSGI: App Import Error

Hi I am new in apache, linux and python world. I am trying to deploy django application on apache using WSGI (the recommended way). My django project directory structure is as follows... / /apache/django.wsgi /apps/ #I put all my apps in this directory /apps/providers/ /apps/shopping/ /apps/... /middleware/ ... In apache I have fo...

Re-ordering child nodes in django-MPTT

I'm using Ben Firshman's fork of django-MPTT (hat tip to Daniel Roseman for the recommendation). I've got stuck trying to re-order nodes which share a common parent. I've got a list of primary keys, like this: ids = [5, 9, 7, 3] All of these nodes have a parent, say with primary key 1. At present, these nodes are ordered [5, 3, 9, 7...

Caching suds-object. Unicode problem

I'm using suds https://fedorahosted.org/suds/ to fetch data using SOAP. I'd like to cache the result (using memcached) to not overload the server from where I'm fetching the data. The problem is when fetching the cached data. Fetching it works fine but then django tries to decode the data (force_unicode) and it fails with the following: ...

Django admin - Restrict user view by permission

Hello, I'm starting to learn Django and I have a question. Is there any way to restric views in the administration interface? I see there are "change, "add" and "delete" permissions, but I wanted to restrict views also. For example: Two users, "User 1" is superuser and "User 2" is in the editor group. User 1 has access to everything, ...

Making a Regex Django URL Token Optional

You have a URL which accepts a first_name and last_name in Django: ('^(?P<first_name>[a-zA-Z]+)/(?P<last_name>[a-zA-Z]+)/$','some_method'), How would you include the OPTIONAL URL token of title, without creating any new lines. What I mean by this is, in an ideal scenario: #A regex constant OP_REGEX = r'THIS IS OPTIONAL<title>[a-z]' #...