Re: Django 1.6.4 debug-toolbar confusing error

2015-03-08 Thread Martin Torre Castro
I have same problem. May it be related to urlconf?

On Friday, 23 May 2014 12:06:19 UTC+2, Florian Auer wrote:
>
> Hi
>
> I am running 2 django 1.6.4 projects, both with debug toolbar enabled.
>
> The first one ist a simple project, following the a cookbook tutorial and 
> the toolbar works fine inside.
> The second project ist the one, I'll wnated to start the real development 
> in.
>
> But there every call to the most panels give me a 500 error:
> Internal Server Error: /__debug__/render_panel/
> Traceback (most recent call last):
>   File "C:\Python33\lib\site-packages\django\core\handlers\base.py", line 
> 114, in get_response
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>   File "C:\Python33\lib\site-packages\debug_toolbar\views.py", line 19, in 
> render_panel
> content = panel.content
>   File "C:\Python33\lib\site-packages\debug_toolbar\panels\__init__.py", 
> line 87, in content
> return render_to_string(self.template, self.get_stats())
>   File "C:\Python33\lib\site-packages\django\template\loader.py", line 
> 162, in render_to_string
> t = get_template(template_name)
>   File "C:\Python33\lib\site-packages\django\template\loader.py", line 
> 138, in get_template
> template, origin = find_template(template_name)
>   File "C:\Python33\lib\site-packages\django\template\loader.py", line 
> 127, in find_template
> source, display_name = loader(name, dirs)
>   File "C:\Python33\lib\site-packages\django\template\loader.py", line 43, 
> in __call__
> return self.load_template(template_name, template_dirs)
>   File "C:\Python33\lib\site-packages\django\template\loader.py", line 49, 
> in load_template
> template = get_template_from_string(source, origin, template_name)
>   File "C:\Python33\lib\site-packages\django\template\loader.py", line 
> 149, in get_template_from_string
> return Template(source, origin, name)
>   File 
> "C:\Python33\lib\site-packages\debug_toolbar\panels\templates\panel.py", 
> line 71, in new_template_init
> old_template_init(self, template_string, origin, name)
>   File "C:\Python33\lib\site-packages\django\template\base.py", line 125, 
> in __init__
> self.nodelist = compile_string(template_string, origin)
>   File "C:\Python33\lib\site-packages\django\template\base.py", line 153, 
> in compile_string
> return parser.parse()
>   File "C:\Python33\lib\site-packages\django\template\base.py", line 278, 
> in parse
> compiled_result = compile_func(self, token)
>   File "C:\Python33\lib\site-packages\django\template\defaulttags.py", 
> line 806, in do_for
> nodelist_loop = parser.parse(('empty', 'endfor',))
>   File "C:\Python33\lib\site-packages\django\template\base.py", line 278, 
> in parse
> compiled_result = compile_func(self, token)
>   File "C:\Python33\lib\site-packages\django\template\defaulttags.py", 
> line 573, in cycle
> PendingDeprecationWarning, stacklevel=2)
> PendingDeprecationWarning: 'The `cycle` template tag is changing to escape 
> its arguments; the non-autoescaping version is deprecated. Load it from the 
> `future` tag library to start using the new behavior.
> [23/May/2014 11:59:50] "GET 
> /__debug__/render_panel/?store_id=e6eeea46ebc04510bf489db8336adf0f&panel_id=SettingsPanel
>  
> HTTP/1.1" 500 14196
>
> the main difference is with this project, that it has a template 
> dependency, using a mysql connector instead of sqlite.
> From my point of view I dont knwo whats the problem.
>
> settings.py:
> # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
> import os
> BASE_DIR = os.path.dirname(os.path.dirname(__file__))
> SECRET_KEY = 'xxx'
> DEBUG = True
> TEMPLATE_DEBUG = True
> ALLOWED_HOSTS = ['127.0.0.1']
> # Application definition
> INSTALLED_APPS = (
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'cockpit',
> )
>
> MIDDLEWARE_CLASSES = (
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> )
> #START addition for DEBUG-TOOLBAR
> INSTALLED_APPS += (
> 'debug_toolbar',
> )
> MIDDLEWARE_CLASSES += (
> 'debug_toolbar.middleware.DebugToolbarMiddleware',
> )
> INTERNAL_IPS = ('127.0.0.1',)
> #DEBUG_TOOLBAR_CONFIG = {'INTERCEPT_REDIRECTS': False} #deprecated
> #END addition for DEBUG-TOOLBAR
>
> #START addition or userauth app
> INSTALLED_APPS += (
> 'userauth',
> )
>
> #START Mobile Detection -> based on mobileESP
> MIDDLEWARE_CLASSES += (
> 'mobileesp.middleware.MobileDetectionMiddleware',
> )
> #END Mobile Detection
>
> ROOT_URLCONF = 'myProjectName

Re: Django 1.6.4 debug-toolbar confusing error

2015-03-08 Thread Martin Torre Castro
I fixed it by following this 

http://django-debug-toolbar.readthedocs.org/en/1.2.2/installation.html

In my case, I had the wrong name in INSTALLED_APPS and I lacked this piece 
of code in urls:

if settings.DEBUG:
import debug_toolbar
urlpatterns += patterns('',
url(r'^__debug__/', include(debug_toolbar.urls)),
)

If anything similar happens to you, pay attention to the most little detail 
in the instructions.

On Friday, 23 May 2014 12:06:19 UTC+2, Florian Auer wrote:
>
> Hi
>
> I am running 2 django 1.6.4 projects, both with debug toolbar enabled.
>
> The first one ist a simple project, following the a cookbook tutorial and 
> the toolbar works fine inside.
> The second project ist the one, I'll wnated to start the real development 
> in.
>
> But there every call to the most panels give me a 500 error:
> Internal Server Error: /__debug__/render_panel/
> Traceback (most recent call last):
>   File "C:\Python33\lib\site-packages\django\core\handlers\base.py", line 
> 114, in get_response
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>   File "C:\Python33\lib\site-packages\debug_toolbar\views.py", line 19, in 
> render_panel
> content = panel.content
>   File "C:\Python33\lib\site-packages\debug_toolbar\panels\__init__.py", 
> line 87, in content
> return render_to_string(self.template, self.get_stats())
>   File "C:\Python33\lib\site-packages\django\template\loader.py", line 
> 162, in render_to_string
> t = get_template(template_name)
>   File "C:\Python33\lib\site-packages\django\template\loader.py", line 
> 138, in get_template
> template, origin = find_template(template_name)
>   File "C:\Python33\lib\site-packages\django\template\loader.py", line 
> 127, in find_template
> source, display_name = loader(name, dirs)
>   File "C:\Python33\lib\site-packages\django\template\loader.py", line 43, 
> in __call__
> return self.load_template(template_name, template_dirs)
>   File "C:\Python33\lib\site-packages\django\template\loader.py", line 49, 
> in load_template
> template = get_template_from_string(source, origin, template_name)
>   File "C:\Python33\lib\site-packages\django\template\loader.py", line 
> 149, in get_template_from_string
> return Template(source, origin, name)
>   File 
> "C:\Python33\lib\site-packages\debug_toolbar\panels\templates\panel.py", 
> line 71, in new_template_init
> old_template_init(self, template_string, origin, name)
>   File "C:\Python33\lib\site-packages\django\template\base.py", line 125, 
> in __init__
> self.nodelist = compile_string(template_string, origin)
>   File "C:\Python33\lib\site-packages\django\template\base.py", line 153, 
> in compile_string
> return parser.parse()
>   File "C:\Python33\lib\site-packages\django\template\base.py", line 278, 
> in parse
> compiled_result = compile_func(self, token)
>   File "C:\Python33\lib\site-packages\django\template\defaulttags.py", 
> line 806, in do_for
> nodelist_loop = parser.parse(('empty', 'endfor',))
>   File "C:\Python33\lib\site-packages\django\template\base.py", line 278, 
> in parse
> compiled_result = compile_func(self, token)
>   File "C:\Python33\lib\site-packages\django\template\defaulttags.py", 
> line 573, in cycle
> PendingDeprecationWarning, stacklevel=2)
> PendingDeprecationWarning: 'The `cycle` template tag is changing to escape 
> its arguments; the non-autoescaping version is deprecated. Load it from the 
> `future` tag library to start using the new behavior.
> [23/May/2014 11:59:50] "GET 
> /__debug__/render_panel/?store_id=e6eeea46ebc04510bf489db8336adf0f&panel_id=SettingsPanel
>  
> HTTP/1.1" 500 14196
>
> the main difference is with this project, that it has a template 
> dependency, using a mysql connector instead of sqlite.
> From my point of view I dont knwo whats the problem.
>
> settings.py:
> # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
> import os
> BASE_DIR = os.path.dirname(os.path.dirname(__file__))
> SECRET_KEY = 'xxx'
> DEBUG = True
> TEMPLATE_DEBUG = True
> ALLOWED_HOSTS = ['127.0.0.1']
> # Application definition
> INSTALLED_APPS = (
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'cockpit',
> )
>
> MIDDLEWARE_CLASSES = (
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> )
> #START addition for DEBUG-TOOLBAR
> INSTALLED_APPS += (
> 'debug_toolbar',
> )
> MIDDLEWARE_CLASSES += (
> 'debug_toolbar.middleware.DebugToolbarMiddleware',
> )
> INTERNAL_IPS = ('127.

Heroku: without NULL bytes error with "2 scoops" structure

2015-06-13 Thread Martin Torre Castro
Hello,

I posted this because I can't deploy a webapp with Heroku. Any ideas?

http://stackoverflow.com/questions/30816367/heroku-string-without-null-bytes-with-several-requirements-files

Thanks for reading

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/71b22802-38aa-485d-8c74-35957d7d4296%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Heroku: without NULL bytes error with "2 scoops" structure

2015-06-14 Thread Martin Torre Castro
I resolved this. I was doing wrong and not making git commit when editing 
requirements.txt files.

On Saturday, 13 June 2015 10:00:18 UTC+2, Martin Torre Castro wrote:
>
> Hello,
>
> I posted this because I can't deploy a webapp with Heroku. Any ideas?
>
>
> http://stackoverflow.com/questions/30816367/heroku-string-without-null-bytes-with-several-requirements-files
>
> Thanks for reading
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0bc141eb-e0b0-42c3-a88e-0744fd8ba8ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Not getting static files with django & heroku deployment

2015-07-04 Thread Martin Torre Castro
Hello,

I'm developing a webapp with Django 1.7 (project_name is "sonata") and the 
project layout from the "Two scoops of Django 1.6", so I have a 3-tier 
basic folder tree.

.├── requirements└── sonata
├── person
│   └── templatetags
├── registration
├── sonata
│   └── settings
├── static
│   ├── css
│   │   └── images
│   ├── fonts
│   └── js
├── templates
│   ├── personApp
│   └── registrationApp
└── utils
└── templatetags


I have a problem when deploying on Heroku. I have achieved the deployment, 
but the static files are not being served to the browser.

I know I should force some way of serving the static files through the 
settings and have googled about. I've seen many ways and read about using 
Amazon services, but I'm looking for the easiest one, which will make the 
future production deployment easy as well with gUnicorn (I hope).

I tried modifying the settings file (which is the heroku.py one, which 
overrides the base.py) and changing values for STATIC_ROOT, 
STATICFILES_DIRS and adding the line:

*urlpatterns += static(settings.MEDIA_URL, 
document_root=settings.STATIC_ROOT)*

I've tried as well running:

*heroku run sonata/manage.py collectstatic*

before doing 

*git push heroku master*

but nothing happens, even checking with 

*heroku run ls sonata/assets *

that the files are being copied.

Please, I would like some orientation for really understanding what I'm 
doing wrong and mending it. 

When finding out about heroku and deployment I met also some sample 
ProcFiles which used a project_name.wsgi file and I don't know anything 
about it.

I could use use some help, because the more webs I read, the more confused 
I get. Please assume I know very little about deployments. A link would be 
useful, but it has to show newbie's material :-(

Thank you very much on advance.


### *ProcFile* 
##
web: python sonata/manage.py runserver 0.0.0.0:$PORT --noreload




### *heroku.py* 
##
# -*- coding: utf-8 -*-
"""Heroku settings and globals."""

from __future__ import absolute_import

from .base import *

from os import environ

# TODO Warning! Heroku retrieve values as strings
# TODO we should check (only for Heroku) that 'True' and 'False' are 
respectively True and False 0, 
# or the equivalent ones, True and False
def get_env_setting(setting):
""" Gets the environment variable or an Exception.
This can be used, for example, for getting the SECRET_KEY and not 
having it hardcoded in the source code 
Also for setting the active settings file for local development, 
heroku, production server, etc... """
try:
return environ[setting]
except KeyError:
error_msg = "Set the %s env variable" % setting
raise ImproperlyConfigured(error_msg)

## HOST CONFIGURATION
# See: 
https://docs.djangoproject.com/en/1.5/releases/1.5/#allowed-hosts-required-in-production
ALLOWED_HOSTS = ['*']
## END HOST CONFIGURATION

## EMAIL CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host
EMAIL_HOST = environ.get('EMAIL_HOST', 'smtp.gmail.com')

# See: 
https://docs.djangoproject.com/en/dev/ref/settings/#email-host-password
EMAIL_HOST_PASSWORD = environ.get('EMAIL_HOST_PASSWORD', '')

# See: 
https://docs.djangoproject.com/en/dev/ref/settings/#email-host-user
EMAIL_HOST_USER = environ.get('EMAIL_HOST_USER', 
'your_em...@example.com')

# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-port
EMAIL_PORT = environ.get('EMAIL_PORT', 587)

# See: 
https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
EMAIL_SUBJECT_PREFIX = '[%s] ' % SITE_NAME

# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-use-tls
EMAIL_USE_TLS = True

# See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email
SERVER_EMAIL = EMAIL_HOST_USER
## END EMAIL CONFIGURATION

## DATABASE CONFIGURATION
import dj_database_url
DATABASES['default'] = dj_database_url.config()
# DATABASES = {}
## END DATABASE CONFIGURATION


## CACHE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
}
}
## END CACHE CONFIGURATION


## SECRET CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settin

Introducing myself and my first question

2014-07-19 Thread Martin Torre Castro
Hello,

my name is Martin and I'm a computer engineer from Spain. I'm going to 
start a new project with a colleague and I decided to use Django because we 
searched for free opensource tools and I'm in love with Python.

We have made a couple of tutorials (the official one and "Tango with 
django"). I've also bought the book "Two scoops of Django" for the 1.6 
Django edition. We're starting the project soon as well as we finish the 
design, but I'm concerned about setting up the new environment. We're 
thinking of using:


   - postgresql
   - Python/Django [ of course ;-) ]
   - Eclipse/Pydev
   - Git
   - jQuery

I've been reading the Greenfield/Roy book and some web sites and I want to 
set up the environment with good practices by using virtualenvwrapper, 
virtualenv, pip, the requirements.txt files and so on.
I have made some mix for all this, but I would be grateful if someone could 
confirm us if we are on the right way, give us some advice or maybe tell us 
where on the internet we can find a good way of doing all this.

My preview for the whole setting up is next:


   1. We should start the installations by installing "sudo apt-get install 
   virtualenvwrapper" . If I understand correctly, this installs virtualenv 
   as well as an embedded pip.
   2. The virtualenv must be created ("virtualenv env") in the parent 
   directory of the Eclipse workspace, I suppose. This is one point of 
   confusion to me. I don't know either if I have to activate this every time 
   I come back for developing resuming the work from days before. I completely 
   understand that later from Eclipse I will give the python path inside the 
   virtualenv, but don't know if must activate the virtualenv every time.
   3. Next step would be to install all the things we need (django, pillow, 
   psycopg2) using a requirements.txt file. "pip install -r requirements.txt
   "
   4. We should create the new django project with a python django-admin.py 
startproject 
   
   5. Now I don't know if we should link the project to an already 
   installed version of Eclipse or run the "git init" first. I understand 
   that Eclipse and Git don't need to be installed inside the virtualenv. In 
   fact, I've been reading and it seems that Eclipse can work OK just by being 
   given the path inside the virtualenv where the python executable is 
   located. I've also read that some people used to make different workspaces, 
   but configuring the paths should be enough 
   http://stackoverflow.com/questions/1145374/virtualenv-with-eclipse-galileo

>From here I would just upload to github or bitbucket, maybe doing the whole 
thing from Eclipse would be easier. But the integration with Eclipse when 
we made tangowithdjango tutorial was the difficult point, because there is 
no option for importing a django project from Eclipse (Kepler version last 
time). We found easier to create the project from Eclipse, but we were not 
using a virtualenv for the tutorial.

I haven't used virtualenv before, so it's our second main obstacle, but I 
expect it will be easy when we get used to it (^_^) .

Please could someone help with some piece of advice, pros and cons of every 
option. Just don't want to do something now I will regret in future.

Thank you veeery much in advance.

PS: Some links visited:
http://www.dabapps.com/blog/introduction-to-pip-and-virtualenv-python/
http://www.tangowithdjango.com/book/chapters/setup.html
https://virtualenv.pypa.io/en/latest/virtualenv.html

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f7332cab-26a7-45fe-a9f5-26831da6bdf4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Advanced SQL Question

2014-07-19 Thread Martin Torre Castro
I suppose you can always switch to the raw SQL queries instead of using 
Django's ORM. 

You have to type more, but it will be more efficient if you know how to 
code SQL for your DB.

On Thursday, 19 June 2014 23:49:52 UTC+2, G Z wrote:
>
> I have a multi-level database that uses concatenated foreign keys as 
> primary keys for tables. 
>
> For example we have three tables
> VMS
> VM_LICENSE
> LICENSES
>
>
> VMS has
> name 
> license_id <- foreign key
> vm_id <-primary key
>
>
> vm_licenses has two concatenated fkeys to for a primary key of:
> licenses_id fkey to licenses
> vm_id   fkey to vms
>
>
> licenses has:
>
> license_id pkey
> product_code
>
>
> how do I deal with concatenated foreign keys to form a primary key how do 
> i even register that in the models.py? 
> The reason I ask is because one i need to register them and the second is 
> how do i save forms based on a concatinated pk
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/82714287-1a90-43de-adb5-0d6b8f3ca8f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Newbie: Complete environment setup(virtualenv, pip, eclipse, git...)

2014-07-19 Thread Martin Torre Castro
Hello,

my name is Martin and I'm a computer engineer from Spain. I'm going to 
start a new project with a colleague and I decided to use Django because we 
searched for free opensource tools and I'm in love with Python.

We have made a couple of tutorials (the official one and "Tango with 
django"). I've also bought the book "Two scoops of Django" for the 1.6 
Django edition. We're starting the project soon as well as we finish the 
design, but I'm concerned about setting up the new environment. We're 
thinking of using:


   - postgresql
   - Python/Django [ of course ;-) ]
   - Eclipse/Pydev
   - Git
   - jQuery

I've been reading the Greenfield/Roy book and some web sites and I want to 
set up the environment with good practices by using virtualenvwrapper, 
virtualenv, pip, the requirements.txt files and so on.
I have made some mix for all this, but I would be grateful if someone could 
confirm us if we are on the right way, give us some advice or maybe tell us 
where on the internet we can find a good way of doing all this.

My preview for the whole setting up is next:


   1. We should start the installations by installing "sudo apt-get install 
   virtualenvwrapper" . If I understand correctly, this installs virtualenv 
   as well as an embedded pip.
   2. The virtualenv must be created ("virtualenv env") in the parent 
   directory of the Eclipse workspace, I suppose. This is one point of 
   confusion to me. I don't know either if I have to activate this every time 
   I come back for developing resuming the work from days before. I completely 
   understand that later from Eclipse I will give the python path inside the 
   virtualenv, but don't know if must activate the virtualenv every time.
   3. Next step would be to install all the things we need (django, pillow, 
   psycopg2) using a requirements.txt file. "pip install -r requirements.txt
   "
   4. We should create the new django project with a python django-admin.py 
startproject 
   
   5. Now I don't know if we should link the project to an already 
   installed version of Eclipse or run the "git init" first. I understand 
   that Eclipse and Git don't need to be installed inside the virtualenv. In 
   fact, I've been reading and it seems that Eclipse can work OK just by being 
   given the path inside the virtualenv where the python executable is 
   located. I've also read that some people used to make different workspaces, 
   but configuring the paths should be enough 
   http://stackoverflow.com/questions/1145374/virtualenv-with-eclipse-galileo

>From here I would just upload to github or bitbucket, maybe doing the whole 
thing from Eclipse would be easier. But the integration with Eclipse when 
we made tangowithdjango tutorial was the difficult point, because there is 
no option for importing a django project from Eclipse (Kepler version last 
time). We found easier to create the project from Eclipse, but we were not 
using a virtualenv for the tutorial.

I haven't used virtualenv before, so it's our second main obstacle, but I 
expect it will be easy when we get used to it (^_^) .

Please could someone help with some piece of advice, pros and cons of every 
option. Just don't want to do something now I will regret in future.

Thank you veeery much in advance.

PS: Some links visited:
http://www.dabapps.com/blog/introduction-to-pip-and-virtualenv-python/
http://www.tangowithdjango.com/book/chapters/setup.html
https://virtualenv.pypa.io/en/latest/virtualenv.html

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c2b90d72-5345-487a-a5ba-0528836f09f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie: Complete environment setup(virtualenv, pip, eclipse, git...)

2014-07-20 Thread Martin Torre Castro
Firstly, I want to say "thank you" to you, Thomas.

Secondly, could you or someone how does the development cycles work with 
virtualenv? Is this way of working just as I wrote? 

I think it works by activating the virtualenv every time with a "source 
activate" command and after that starting to program from the terminal. I 
need to know this for adapting Eclipse to activating the virtualenv every 
times it opens if virtualenv works as expected.

Thanks



On Sunday, 20 July 2014 04:29:53 UTC+2, Thomas wrote:
>
>  On 7/19/14 6:41 PM, Martin Torre Castro wrote:
>  
>  Hello,
>
>  my name is Martin and I'm a computer engineer from Spain. I'm going to 
> start a new project with a colleague and I decided to use Django because we 
> searched for free opensource tools and I'm in love with Python.
>
>  We have made a couple of tutorials (the official one and "Tango with 
> django"). I've also bought the book "Two scoops of Django" for the 1.6 
> Django edition. We're starting the project soon as well as we finish the 
> design, but I'm concerned about setting up the new environment. We're 
> thinking of using:
>
>  
>- postgresql 
>- Python/Django [ of course ;-) ] 
>- Eclipse/Pydev
> - Git 
>- jQuery 
>
>  
>  All good choices. pip and virtualenv provide for a reproducible and 
> robust installation. PostgreSQL is imho far superior to other options for 
> db. I don't have experience with using Eclipse in this environment so can't 
> comment there.
>
> hth
>
>- Tom
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f99612a0-0d8f-44ee-93ee-2ed3e01055f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie: Complete environment setup(virtualenv, pip, eclipse, git...)

2014-07-21 Thread Martin Torre Castro
Thanks Mulianto, ngangsia and Tom.

I'm working in Ubuntu but I will take advantage of your instructions 
ngangsia when setting up all the "machinery".

Thanks also Tom, for the advice and the requirements tip, as this will be 
another thing we're trying for the first time in future.

On Sunday, 20 July 2014 03:41:11 UTC+2, Martin Torre Castro wrote:
>
> Hello,
>
> my name is Martin and I'm a computer engineer from Spain. I'm going to 
> start a new project with a colleague and I decided to use Django because we 
> searched for free opensource tools and I'm in love with Python.
>
> We have made a couple of tutorials (the official one and "Tango with 
> django"). I've also bought the book "Two scoops of Django" for the 1.6 
> Django edition. We're starting the project soon as well as we finish the 
> design, but I'm concerned about setting up the new environment. We're 
> thinking of using:
>
>
>- postgresql
>- Python/Django [ of course ;-) ]
>- Eclipse/Pydev
>- Git
>- jQuery
>
> I've been reading the Greenfield/Roy book and some web sites and I want to 
> set up the environment with good practices by using virtualenvwrapper, 
> virtualenv, pip, the requirements.txt files and so on.
> I have made some mix for all this, but I would be grateful if someone 
> could confirm us if we are on the right way, give us some advice or maybe 
> tell us where on the internet we can find a good way of doing all this.
>
> My preview for the whole setting up is next:
>
>
>1. We should start the installations by installing "sudo apt-get 
>install virtualenvwrapper" . If I understand correctly, this installs 
>virtualenv as well as an embedded pip.
>2. The virtualenv must be created ("virtualenv env") in the parent 
>directory of the Eclipse workspace, I suppose. This is one point of 
>confusion to me. I don't know either if I have to activate this every time 
>I come back for developing resuming the work from days before. I 
> completely 
>understand that later from Eclipse I will give the python path inside the 
>virtualenv, but don't know if must activate the virtualenv every time.
>3. Next step would be to install all the things we need (django, 
>pillow, psycopg2) using a requirements.txt file. "pip install -r 
>requirements.txt"
>4. We should create the new django project with a python 
>django-admin.py startproject 
>5. Now I don't know if we should link the project to an already 
>installed version of Eclipse or run the "git init" first. I understand 
>that Eclipse and Git don't need to be installed inside the virtualenv. In 
>fact, I've been reading and it seems that Eclipse can work OK just by 
> being 
>given the path inside the virtualenv where the python executable is 
>located. I've also read that some people used to make different 
> workspaces, 
>but configuring the paths should be enough 
>http://stackoverflow.com/questions/1145374/virtualenv-with-eclipse-galileo
>
> From here I would just upload to github or bitbucket, maybe doing the 
> whole thing from Eclipse would be easier. But the integration with Eclipse 
> when we made tangowithdjango tutorial was the difficult point, because 
> there is no option for importing a django project from Eclipse (Kepler 
> version last time). We found easier to create the project from Eclipse, but 
> we were not using a virtualenv for the tutorial.
>
> I haven't used virtualenv before, so it's our second main obstacle, but I 
> expect it will be easy when we get used to it (^_^) .
>
> Please could someone help with some piece of advice, pros and cons of 
> every option. Just don't want to do something now I will regret in future.
>
> Thank you veeery much in advance.
>
> PS: Some links visited:
> http://www.dabapps.com/blog/introduction-to-pip-and-virtualenv-python/
> http://www.tangowithdjango.com/book/chapters/setup.html
> https://virtualenv.pypa.io/en/latest/virtualenv.html
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/397abd48-4a73-42dd-8350-ea1c6be48fe1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Introducing myself and my first question

2014-07-21 Thread Martin Torre Castro
Thanks to you both.

I know the URL, Ariel, and I will look at it when beginning the 
implementation.

Thanks Cal for the comments. I've been heard very well about Sublime Text 
and I'm planning ot use it, not as a IDE, but for other issues as a 
complementary editor.

On Sunday, 20 July 2014 03:48:37 UTC+2, Edward Chen wrote:
>
> Hi - I am kind of new myself, and I don't have all the answers to your 
> questions, but here are some thoughts, and I could be wrong.
>
> 1.  You can set up your virtualenv anywhere you like.  The one I'm using 
> right now is in ~/Envs/venv_for_my_project/  All you're doing with it is 
> source/bin/activate.  As Two Scoops of Django recommends, just store the 
> output of pip freeze in version control.
>
> 2. I am not using Eclipse, so I can't help there.  I am using PyCharm 
> which has a nice integration with virtualenv and Django.  It's easy to 
> start the server in debugging mode and set break points.  With Pycharm, I 
> set it up once, pointing it to the location of my virtualenv, and haven't 
> touched it since, even though I've added packages to my virtualenv.  The 
> downside of PyCharm is that it costs money.
>
> 3. I don't think you can screw things up too much.  You may want to first 
> do as much as possible via the command line in a terminal window and see if 
> that works (for example, start and stop the server), then try the same 
> thing through Eclipse's interface.  The worst that can happen is that your 
> test server doesn't work.
>
>   
>
>
> On Sat, Jul 19, 2014 at 3:09 PM, Martin Torre Castro  > wrote:
>
>> Hello,
>>
>> my name is Martin and I'm a computer engineer from Spain. I'm going to 
>> start a new project with a colleague and I decided to use Django because we 
>> searched for free opensource tools and I'm in love with Python.
>>
>> We have made a couple of tutorials (the official one and "Tango with 
>> django"). I've also bought the book "Two scoops of Django" for the 1.6 
>> Django edition. We're starting the project soon as well as we finish the 
>> design, but I'm concerned about setting up the new environment. We're 
>> thinking of using:
>>
>>
>>- postgresql
>>- Python/Django [ of course ;-) ]
>>- Eclipse/Pydev
>>- Git
>>- jQuery
>>
>> I've been reading the Greenfield/Roy book and some web sites and I want 
>> to set up the environment with good practices by using virtualenvwrapper, 
>> virtualenv, pip, the requirements.txt files and so on.
>> I have made some mix for all this, but I would be grateful if someone 
>> could confirm us if we are on the right way, give us some advice or maybe 
>> tell us where on the internet we can find a good way of doing all this.
>>
>> My preview for the whole setting up is next:
>>
>>
>>1. We should start the installations by installing "sudo apt-get 
>>install virtualenvwrapper" . If I understand correctly, this installs 
>>virtualenv as well as an embedded pip.
>>2. The virtualenv must be created ("virtualenv env") in the parent 
>>directory of the Eclipse workspace, I suppose. This is one point of 
>>confusion to me. I don't know either if I have to activate this every 
>> time 
>>I come back for developing resuming the work from days before. I 
>> completely 
>>understand that later from Eclipse I will give the python path inside the 
>>virtualenv, but don't know if must activate the virtualenv every time. 
>>3. Next step would be to install all the things we need (django, 
>>pillow, psycopg2) using a requirements.txt file. "pip install -r 
>>requirements.txt"
>>4. We should create the new django project with a python 
>>django-admin.py startproject  
>>5. Now I don't know if we should link the project to an already 
>>installed version of Eclipse or run the "git init" first. I 
>>understand that Eclipse and Git don't need to be installed inside the 
>>virtualenv. In fact, I've been reading and it seems that Eclipse can work 
>>OK just by being given the path inside the virtualenv where the python 
>>executable is located. I've also read that some people used to make 
>>different workspaces, but configuring the paths should be enough 
>>
>> http://stackoverflow.com/questions/1145374/virtualenv-with-eclipse-galileo 
>>
>> From here I would just upload to github or bitbucket, maybe doing the 
>

Re: Introducing myself and my first question

2014-07-21 Thread Martin Torre Castro
Thanks to you also, Chen, I read you the last, but not least. I looked at 
PyCharm's price but it seemed expensive for buying for being used by two 
people at developing.

I take care of the 'pip freeze' tip. :-)

On Sunday, 20 July 2014 03:48:37 UTC+2, Edward Chen wrote:
>
> Hi - I am kind of new myself, and I don't have all the answers to your 
> questions, but here are some thoughts, and I could be wrong.
>
> 1.  You can set up your virtualenv anywhere you like.  The one I'm using 
> right now is in ~/Envs/venv_for_my_project/  All you're doing with it is 
> source/bin/activate.  As Two Scoops of Django recommends, just store the 
> output of pip freeze in version control.
>
> 2. I am not using Eclipse, so I can't help there.  I am using PyCharm 
> which has a nice integration with virtualenv and Django.  It's easy to 
> start the server in debugging mode and set break points.  With Pycharm, I 
> set it up once, pointing it to the location of my virtualenv, and haven't 
> touched it since, even though I've added packages to my virtualenv.  The 
> downside of PyCharm is that it costs money.
>
> 3. I don't think you can screw things up too much.  You may want to first 
> do as much as possible via the command line in a terminal window and see if 
> that works (for example, start and stop the server), then try the same 
> thing through Eclipse's interface.  The worst that can happen is that your 
> test server doesn't work.
>
>   
>
>
> On Sat, Jul 19, 2014 at 3:09 PM, Martin Torre Castro  > wrote:
>
>> Hello,
>>
>> my name is Martin and I'm a computer engineer from Spain. I'm going to 
>> start a new project with a colleague and I decided to use Django because we 
>> searched for free opensource tools and I'm in love with Python.
>>
>> We have made a couple of tutorials (the official one and "Tango with 
>> django"). I've also bought the book "Two scoops of Django" for the 1.6 
>> Django edition. We're starting the project soon as well as we finish the 
>> design, but I'm concerned about setting up the new environment. We're 
>> thinking of using:
>>
>>
>>- postgresql
>>- Python/Django [ of course ;-) ]
>>- Eclipse/Pydev
>>- Git
>>- jQuery
>>
>> I've been reading the Greenfield/Roy book and some web sites and I want 
>> to set up the environment with good practices by using virtualenvwrapper, 
>> virtualenv, pip, the requirements.txt files and so on.
>> I have made some mix for all this, but I would be grateful if someone 
>> could confirm us if we are on the right way, give us some advice or maybe 
>> tell us where on the internet we can find a good way of doing all this.
>>
>> My preview for the whole setting up is next:
>>
>>
>>1. We should start the installations by installing "sudo apt-get 
>>install virtualenvwrapper" . If I understand correctly, this installs 
>>virtualenv as well as an embedded pip.
>>2. The virtualenv must be created ("virtualenv env") in the parent 
>>directory of the Eclipse workspace, I suppose. This is one point of 
>>confusion to me. I don't know either if I have to activate this every 
>> time 
>>I come back for developing resuming the work from days before. I 
>> completely 
>>understand that later from Eclipse I will give the python path inside the 
>>virtualenv, but don't know if must activate the virtualenv every time. 
>>3. Next step would be to install all the things we need (django, 
>>pillow, psycopg2) using a requirements.txt file. "pip install -r 
>>requirements.txt"
>>4. We should create the new django project with a python 
>>django-admin.py startproject  
>>5. Now I don't know if we should link the project to an already 
>>installed version of Eclipse or run the "git init" first. I 
>>understand that Eclipse and Git don't need to be installed inside the 
>>virtualenv. In fact, I've been reading and it seems that Eclipse can work 
>>OK just by being given the path inside the virtualenv where the python 
>>executable is located. I've also read that some people used to make 
>>different workspaces, but configuring the paths should be enough 
>>
>> http://stackoverflow.com/questions/1145374/virtualenv-with-eclipse-galileo 
>>
>> From here I would just upload to github or bitbucket, maybe doing the 
>> whole thing from Eclipse would be easier. But

Multi-table inheritance models not working for me

2014-10-08 Thread Martin Torre Castro
Hello,

I want to make a hierarchy over a DB design as described in "Fundamentals 
of database systems" from Elmasri & Navathe. 

This implies that when I have some info which is shared for many 
classes/tables, I can put it in a main parent table and use the main table 
id as foreign key in the child tables, kind of a weak entity.

I tried using abstract and multitable inheritance (this last one doesn't 
let me specify the OneToOneField, don't know where to find this at django 
docs).

My example is right down here (one table per class):

'''I would like this to be abstract, because I will never instantiate 
it, 
but could be not if needed'''

class Person(models.Model): 
personId = models.IntegerField(primary_key=True)
name = models.CharField(max_length=45)
surname = models.CharField(max_length=45, blank=True)
email = models.CharField(max_length=45, blank=True)
phone = models.CharField(max_length=15, blank=True)

class Meta:
managed = False
db_table = 'person'

class Alumn(Person):
# Maybe this one down should be OneToOne.
# alumnId == personId always true for the same real world guy
alumnId = models.ForeignKey('Person', db_column='alumnId', 
primary_key=True) 


   
comments = models.CharField(max_length=255, blank=True)

class Meta:
managed = False
db_table = 'alumn'

# There are more child classes (Client, Professor, etc) 
# but for the example this is enough

My target is achieving to create an Alumn in DB just with two sentences 
like:


a = Alumn(personId=1,name='Joe', [...more params...] , alumnId=1, 
comments='Some comments' )
a.save()


and having these two lines insert two rows: one for Person and one for 
Alumn. The alumnId attribute in this snippet up here could be omitted, 
because it will always be the same as the personId (I told you, like a weak 
entity).

I'm quite a beginner at django but I have looked at the documentation and 
proved some things with abstract=True in Person and not having succeeded I 
guess now that I should mess with the __init__ constructors for getting the 
superclass built and after that build the child class.

I don't know the right path to choose but definitely want not to alter the 
database design. Please help.

Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e25813f2-6205-4457-83fe-8fadffddda69%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to deny access to a logged user directly to a specific URL

2014-10-17 Thread Martin Torre Castro
Hello,

at my project we need some sort of system for allowing/denying some access 
to an URL.

The example, we want to make some kind of wizard. 


   1. The user inputs the first object at the the first screen (A screen), 
   and then he press "Continue".
   2. Now we get the data and redirect to a second screen (B screen), where 
   we the user should enter a second object.
   3. The wizard goes on...

The problem is that if we do so, the user can write the B url at the 
browser and access the B screen. The user has made the login, but even so, 
we don't want him to get there without passing through A screen.

We don't know how to achieve this or look for this in internet. We only 
know about user session for doing this.

Is there another way? Some help?

Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b374d3d6-c485-4388-91ed-3d128ba51b72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Advice about composing several templates

2015-01-04 Thread Martin Torre Castro
Hello,

I'm developing a web application with Django and we have met a dilemma 
about the design.

We were making one template for every screen, but right now we have 
detected that some parts of of the screen with the information are repeated 
all over the different screens. For example, when coming to show personal 
data of a person, you can show also another data concerning that person, 
but not personal data (financial data, for instance).

My intuition told me that we should look for a solution in which we could 
make small templates that we could compose, combine and concatenate and 
that we should also make different views or functions which would return 
its own associated template each one. 

Thus, *person_data()* would return the rendered template showing the name, 
surname, address, etc... and *financial_data()* would return the rendered 
template showing the salary, bank account, etc... After that, the desirable 
thing would be concatenating both or inserting them in a wider template for 
showing all this together.


...
{# Some html code here #}
...
{# *person_data template* #}
...
...
{# *financial_data template* #}
...
{# Some html code here #}
...


So as always I made some research on the net and I found:


https://docs.djangoproject.com/en/dev/ref/templates/builtins/#include

a link which describes how to use include for inserting a template file in 
another template:

{% include "foo/bar.html" %}


And you can also use a variable from the python function with the path name or 
an object with render method:

{% include template_name %}

So we could use all this in this way for combining, concatenating, composing 
and operating on templates. We could choose the one which includes the others 
and passing it the context for all templates (I suppose, I didn't test 
anything). But I don't know if I'm well directed or if this is the best way to 
go. I would appreciate some advice.


I also found another interesting thread in stackoverflow talking about this:

http://stackoverflow.com/questions/10985950/how-do-you-insert-a-template-into-another-template

My idea is to have small templates which are used repeatedly in different spots 
of the web and composing them in Unix-like style, so I would have small visual 
pieces that would be used once and again saving a lot of hours of writing of 
code.


Please some advice.

Thanks in advance

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/440ce641-83aa-4cba-b2a9-566cdbc59344%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How and where should I put a version number in my Django project?

2016-05-03 Thread Martin Torre Castro


I'm making a Django project consisting of several apps and I want to use a 
version number for the whole project, which would be useful for tracking 
the status of the project between each time it comes to production.


I've read and googled and I've found how to put a version number for each 
django app of mine, but not for a whole project.

I assume that the *settings.py* (in my case it would be base.py, because 
the settings are inherited for each environment: developmente, 
pre-production, production) would be the ideal file for storing it, but I 
would like to know good practices from other Django programmers, because I 
haven't found any.


Thank you in advance

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1487d708-62f4-4ea0-844b-c61107e58746%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Not getting static files with django & heroku deployment

2015-09-19 Thread Martin Torre Castro
At the end I used WhiteNoise.

If anyone there wants to know about how I made the configuration, just 
write. :-)

On Sunday, 5 July 2015 09:00:43 UTC+2, Martín Torre Castro wrote:
>
> I have just read now your mail when awakening. I also love the work from 
> Danny and Audrey and got his las two books "2 scoops...".
>
> I will look about this links along today (kind of holidays here) and 
> answer soon.
>
> Thanks
> El 5/7/2015 3:44 a. m., "Malik Rumi" > 
> escribió:
>
>> Hi Martin,
>>
>> First let me say unapologetically that I love PyDanny and his work and 
>> contributions to the Django community, especially Two Scoops. However, you 
>> should know that the philosophy he espouses there is very different from 
>> the one Heroku espouses. I've been told he talks about that somewhere, but 
>> I've never seen it personally. 
>>
>> I won't go into too much detail, but you can read about it here: 
>> https://devcenter.heroku.com/articles/architecting-apps
>>
>> What you need more than anything is the Heroku Django template :  
>> https://devcenter.heroku.com/articles/django-app-configuration
>>
>> Try that first. Follow the directions carefully, then let us know if you 
>> still need help. 
>>
>>
>> On Saturday, July 4, 2015 at 7:13:39 PM UTC-5, Martin Torre Castro wrote:
>>>
>>> Hello,
>>>
>>> I'm developing a webapp with Django 1.7 (project_name is "sonata") and 
>>> the project layout from the "Two scoops of Django 1.6", so I have a 3-tier 
>>> basic folder tree.
>>>
>>> .├── requirements└── sonata
>>> ├── person
>>> │   └── templatetags
>>> ├── registration
>>> ├── sonata
>>> │   └── settings
>>> ├── static
>>> │   ├── css
>>> │   │   └── images
>>> │   ├── fonts
>>> │   └── js
>>> ├── templates
>>> │   ├── personApp
>>> │   └── registrationApp
>>> └── utils
>>> └── templatetags
>>>
>>>
>>> I have a problem when deploying on Heroku. I have achieved the 
>>> deployment, but the static files are not being served to the browser.
>>>
>>> I know I should force some way of serving the static files through the 
>>> settings and have googled about. I've seen many ways and read about using 
>>> Amazon services, but I'm looking for the easiest one, which will make the 
>>> future production deployment easy as well with gUnicorn (I hope).
>>>
>>> I tried modifying the settings file (which is the heroku.py one, which 
>>> overrides the base.py) and changing values for STATIC_ROOT, 
>>> STATICFILES_DIRS and adding the line:
>>>
>>> *urlpatterns += static(settings.MEDIA_URL, 
>>> document_root=settings.STATIC_ROOT)*
>>> 
>>> I've tried as well running:
>>>
>>> *heroku run sonata/manage.py collectstatic*
>>> 
>>> before doing 
>>>
>>> *git push heroku master*
>>>
>>> but nothing happens, even checking with 
>>>
>>> *heroku run ls sonata/assets *
>>>
>>> that the files are being copied.
>>>
>>> Please, I would like some orientation for really understanding what I'm 
>>> doing wrong and mending it. 
>>>
>>> When finding out about heroku and deployment I met also some sample 
>>> ProcFiles which used a project_name.wsgi file and I don't know anything 
>>> about it.
>>>
>>> I could use use some help, because the more webs I read, the more 
>>> confused I get. Please assume I know very little about deployments. A link 
>>> would be useful, but it has to show newbie's material :-(
>>>
>>> Thank you very much on advance.
>>>
>>>
>>> ### *ProcFile* 
>>> ##
>>> web: python sonata/manage.py runserver 0.0.0.0:$PORT --noreload
>>>
>>>
>>>
>>>
>>> ### *heroku.py* 
>>> ##
>>> # -*- coding: utf-8 -*-
>>> """Heroku settings and globals."""
>>> 
>>> from __future__ import absolute_import
>>> 
>>> from .base import *
>>> 
>>> from os import environ
>

Best way to trigger javascript function when returning a page from django view

2015-09-19 Thread Martin Torre Castro
Hello,

I have a django project where I make requests to the server views both by 
AJAX and the usual  simple URL requests to Django.

The thing is that I have made one javascript function for storing the forms 
contents in the HTML5 webstorage and I want to clear the stored data after 
coming from a succesful operation, beacuse the flow is:

1. You get to the form

2. You enter the data into the form

3. Press submit
   a. If there is a validation error, we come back to 3 and the javascript 
function fills the same data entered into the form (this is already done 
and is awesome and comfortable for the user)

4. If all data was valid and OK, after returning from the python/django 
view I want to trigger the javascript function that clears the stored data, 
because is saved and we don't need it anymore because it's already saved. *This 
is my problem*


When returning to an AJAX I can simply use the success function in 
jQuery.get() o jQuery.ajax(), but when returning from a regular view I 
can't think of any strategy other than passing the flow to a success page, 
in which I trigger the function with $(document).ready(). 

I'm looking for the best alternative, because it would be better not 
forcing me to pass through a specific page. Any ideas?


Thank you in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bffd59a7-c30f-4092-8160-30ef7e472b27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: DJANGO

2015-09-19 Thread Martin Torre Castro
Search in Google "tangowithdjango" and "gettingstartedwithdjango".


The first one maybe is best fr beginners

On Thursday, 10 September 2015 17:41:07 UTC+2, Arindam sarkar wrote:
>
> The django tutorial itselt 
> https://docs.djangoproject.com/en/1.8/intro/tutorial01/
> On Thu, Sep 10, 2015 at 8:00 PM, Nishant Shetty  > wrote:
>
>> BEST DJANGO TUTORIAL ON WEB?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/e00fdb5d-2d0c-4b34-8ebc-d794ec46ed1d%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Regards,
>
> Arindam
>
> Contact no. 08732822385
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c3aeb955-4a1f-4dca-be7f-433d4c8c3bcd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Ajax in Django

2015-09-19 Thread Martin Torre Castro
If you use jQuery (I do), making AJAX requests is incredibly easy. Just use 
the $.get(), $.post() or $.ajax() functions.

If you have any doubt, the api.jquery.com page has all the references and 
information for using them (search for jQuery.get(), jQuery.post() and 
jQuery.ajax() ).

On Monday, 31 August 2015 16:04:45 UTC+2, Dheerendra Rathor wrote:
>
> Ajax are just normal HTTP requests. You can write a view in your code 
> which returns data from db. If it is a post requests then make sure you're 
> adding "csrfmiddlewaretoken" in the ajax data. 
>
> On Mon, 31 Aug 2015 at 19:30 jasir1903 > 
> wrote:
>
>> How to retrive Data from Db in Django to Template using Ajax? I am new to 
>> Django i need to retrive the data WITHOUT PAGE REFRESH USING AJAX please 
>> help me with that..
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/c4c35ccb-ed72-4850-87f5-730310f37883%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d7e1339c-1b5f-41c6-b809-5c0296e84ddf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Forms questions

2015-09-19 Thread Martin Torre Castro
If there's a file in the form data, I'm no expert but I have fought a 
little with forms and files and I advise you to look in the internet for 
multipart forms and file inputs inside forms.

On Tuesday, 25 August 2015 21:12:46 UTC+2, Hugo Kitano wrote:
>
> I've realized that the action field in the form should be 
> "/stats/submit/", the same view as the one that sent me to the template.  
> However, whenever I submit with the form then, it tells me that the file I 
> submit is missing, even when it is definitely there.
>
> On Tuesday, August 25, 2015 at 10:10:30 AM UTC-7, Hugo Kitano wrote:
>>
>> Here it is, very simple:
>>
>>  Submit form: 
>> 
>> {% csrf_token %}
>> {{ form.as_p }}
>> 
>> 
>>
>>
>>
>> On Monday, August 24, 2015 at 4:31:47 PM UTC-7, Sait Maraşlıoğlu wrote:
>>>
>>> Can you provide the template code?
>>>
>>>
>>> On Tuesday, 25 August 2015 00:16:40 UTC+3, Hugo Kitano wrote:

 Hi, I'm trying to figure out what's wrong with my form:

 I've noticed that every time I load my submit view, the request.method 
 is GET not POST, so nothing gets saved to the database.


 Here's views.py


 models.py


 Thanks!!



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dfa54e00-a8d4-4e02-9955-7c692e209f4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


What am I supposed to do if I want a Wizard?

2015-12-09 Thread Martin Torre Castro
Hello,

I was investigating about form wizards in Django, but I have seen that 
recently this has changed in the deprecation timeline doc:

"The form wizard has been refactored to use class-based views with 
pluggable backends in 1.4. The previous implementation will be removed."

I understand that the old form wizard is now part of the form-tools package 
and I must install it if I want to use it.

My question is if I should do it or maybe I should "use class based-views 
with pluggable backends", which I'm not sure of what means and sounds like 
doing all the classes and boilerplate for doing wizards all again on my own.


Please, could someone give me some advice. If I go with class based views, 
could someone pass me a link where I can find some example with a form 
wizard made in such way.


Thank you very much in advanced.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ac8fecc6-baed-4b40-8f71-bfdc17a69ee7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django formtools wizard produces blank page (No error returned)

2016-01-30 Thread Martin Torre Castro
I'm trying to use the formwizard in formtools package with no success (I 
was able to do it when the package was inside Django in earlier versions). 

The only response I got is:

[23/Jan/2016 11:06:50]"GET /registration/wizard HTTP/1.1" 200 13729

and a blank page. No errors in browser or Eclipse console.

There's no way of googling without errors. Please help.

Thanks in advance

(If you guys find more comfortable stackoverflow, you can go to 
http://stackoverflow.com/q/34962499/1241715)


*What did I do?*

Firstly, I installed the formtools package with pip:

django-formtools==1.0
Django==1.8.3


Following the instructions of the official docs:


   1. Define form classes
   
   *registration/forms.py*
   
   class StepForm1(forms.Form):
   first_field = forms.CharField(max_length=100)
   second_field = forms.CharField()
   
   class StepForm2(forms.Form):
   message = forms.CharField(widget=forms.Textarea)
   
   2. Create WizardView
   
   
*registration/views.py *
   TEST_TEMPLATES = {"test_step_1": "registration/test_step1.html", 
   "test_step_2": "registration/test_step2.html", }
   
   from formtools.wizard.views import SessionWizardView
   
   class WizardTest(SessionWizardView):
   template_name = 'registration/test_wizard.html'
   
   # Return templates for each step
   def get_templates_name(self):
   return [TEST_TEMPLATES[self.steps.current]]
   
   # Method called when all is done
   def done(self, form_list, **kwargs):
   # return HttpResponseRedirect('/url-to-redirect-to/') 
   
   # We return the final template with the info
   return render_to_response('test_done.html', {

 'form_data':[form.cleaned_data for form in form_list],

 })
   # THESE METHODS BELOW ARE NOT NEEDED, BUT COMMENTED FOR FUTURE USE
   
   # Not strictly needed. Returns data for a step
   # or None if form is not valid
   
   # def get_cleaned_data_for_step(self, step):
   #return None
   
   # Form data postprocessing in a concrete wizard step
   # def process_step(self, form):
   #return self.get_form_step_data(form)
   
   # Handles value from a step before storing them into wizard
   # def get_form_step_data(self, form):
   #return form.data
   
   3. Create the templates
   
   *registration/test_step1.html*
   
   Two fields form
   
   
   
   
*registration/test_step2.html *
   Message form
   
   
   
*registration/test_wizard.html *
   {% extends "person/alumnos.html" %}
   {% load i18n %}
   
   {% block head %}
   {{ wizard.form.media }}
   {% endblock head %}
   
   {% block content %}
   {% trans "Step {{wizard.steps.step1}} of {{wizard.steps.count}}" 
   %}
   
   {% csrf_token %}
   
   {{ wizard.management_form }}
   {% if wizard.form.forms  %}
   {{ wizard.form.management_form }}
   {% for form in wizard.form.forms %}
   {{form}}
   {% endfor %}
   {% else %}
   {{ wizard.form }}
   {% endif %}
   
   {% if wizard.steps.prev %}
   {% trans "Beginning" %}
   {% trans "Previous step" %}
   {% endif %}
   
   
   
   {% endblock %}
   
   4. Add 'formtools' to my INSTALLED_APPS
   
   
*settings.py *
   DJANGO_APPS = (
   # Default Django apps:
   'django.contrib.auth',
   'django.contrib.contenttypes',
   'django.contrib.sessions',
   'django.contrib.sites',
   'django.contrib.messages',
   'django.contrib.staticfiles',
   
   'formtools', # <= HERE
   
   # Useful template tags:
   # 'django.contrib.humanize',
   # Admin panel and documentation:
   'django.contrib.admin',
   # 'django.contrib.admindocs',
   )
   
   # Apps specific for this project go here.
   LOCAL_APPS = (
   'person',
   'registration',
   'teaching',
   'utils',
   )
   
   # See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
   INSTALLED_APPS = DJANGO_APPS + LOCAL_APPS
   
   5. Point my URLconf at your WizardView as_view() method.
   
   
*registration/urls.py *
   from registration.forms import StepForm1, StepForm2
   
   TEST_FORMS = [("test_step_1", StepForm1), ("test_step_2", StepForm2), ]
   
   from registration.views import WizardTest
   
   # I tried in two ways, none of them worked
   
   urlpatterns = patterns('',
   url(r'^wizard$', WizardTest.as_view(TEST_FORMS), name='wizard_test'),
   url(r'^wizard2$', views.wizard, name='wizard_test'),
   )
   
   For the second way...
   
   
*registration/views.py *
   def wizard(request):
   return WizardTest.as_view(TEST_FORMS)(request)
   
   
   

-- 
You received this message because you