Re: problem with deploying django using mod wsgi

2013-08-07 Thread Nick Dokos
sah  writes:

> Though i remove those two line it did not change anything. It works
> the same as before, i get the search_form page and if i give some
> value for search, I get a 404 error page saying that the page is not
> available in the server.
>

Then check the /var/log/apache2/error.log file on the server to see what
URL is being passed. I often do a `tail -f' on that file in an xterm
window so I can watch for errors.  And you might want to turn up the
verbosity of your server in /etc/apache2/apache2.conf - look for
LogLevel:

,
| #
| # LogLevel: Control the number of messages logged to the error_log.
| # Possible values include: debug, info, notice, warn, error, crit,
| # alert, emerg.
| #
| LogLevel warn
`

-- 
Nick

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Foreign Key problems with legacy database

2013-07-23 Thread Nick Dokos
Avraham Serour  writes:

> you don't need songid = models.Integerfield()

... and the ForeignKey should not specify a db_column.

>
> On Tue, Jul 23, 2013 at 6:04 AM, Brian Millham  wrote:
>
> I have the following models:
>
> class Requestlist(models.Model):
>    id = models.IntegerField(primary_key=True)
>    songid = models.Integerfield()
>    song = ForeignKey('Song', db_column='songid')
> class Song(models.Model):
>   id = models.IntegerField(primary_key=True)
>   title = models.CharField(max_length=255L)
>
--
Nick

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Views, Forms not working.

2013-07-01 Thread Nick Dokos
Nigel Legg  writes:

> template datatables.html:
> 
> 
> 
>     Make Tables
> 
>     
>      enctype="multipart/formdata">{% csrf_token %}
>    
>      {{ form.datFile.label_tag }} {{ form.datFile }} 
>      {{ form.structFile.label_tag }} {{ form.structFile }} 
> 
>      {{ form.bannerVar.label_tag}} {{ form.bannerVar }} 
> 
>      {{ form.stubVar.label_tag}} {{ form.stubVar }} 
>      {{ form.stubNets.label_tag }} {{ form.stubNets }} 
>
>     
>
> 
> 
>

Nothing to do with the problem, so just an fyi:  and  are missing.

-- 
Nick

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Problem setting up django server

2013-06-18 Thread Nick Dokos
smy28  writes:

> Okay, so I ran python manage.py shell and I got the following error:
> TypeError: Error when calling the metaclass bases
> __init__() keywords must be strings
>

I'd suggest that you remove everything and start from scratch. Make
sure that all the requirements are met and that you are
getting the versions you think you are getting: starting python will
tell you the version. Also check which django-admin.py you are using (in
case you have more than one installed on your system) - if you are on
linux or a unix-y system, the command 

 $ which django-admin.py

will tell you.

I tried to duplicate your problem (I'm running python 2.7.3 and django
1.5). For the record, I do

$ django-admin.py startproject foo
$ cd foo
$ python manage.py shell

and I get no errors.

-- 
Nick

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Problem with csrf

2013-06-12 Thread Nick Dokos
MattDale  writes:

> You are correct in assuming that your first view using
> render_to_response shouldn't work without sending a RequestContext in.

> A much cleaner way is just to use the render function.
> https://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render
> which takes a lot of typing out of the typical render_to_response with
> RequestContext.
>

OK - thanks! I tried the render() approach and it works fine. I'll be
using that one.

There is still the question of whether the doc needs fixing. I take it
you are saying that it does?
-- 
Nick

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Problem with csrf

2013-06-12 Thread Nick Dokos
I have a simple application and it DTRT before turning on CSRF
(this is on Django 1.5.1). So I tried to follow the documentation
to turn on CSRF detection and was getting intro trouble.

First I tried to follow this page:

   https://docs.djangoproject.com/en/1.5/ref/contrib/csrf/

I did steps 1 and 2 (uncommenting the csrf middleware in
MIDDLEWARE_CLASSES and adding {% csrf_token %} to my (one and only)
POST form) and then tried step 3.2:

--8<---cut here---start->8---
from django.core.context_processors import csrf
from django.shortcuts import render_to_response

def my_view(request):
c = {}
c.update(csrf(request))
# ... view code here
return render_to_response("a_template.html", c)
--8<---cut here---end--->8---

where I added my dictionary entries to c before passing it to
render_to_response.

That did not work - the development server said:

,
| /usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py:58:
| UserWarning: A {% csrf_token %} was used in a template, but the context
| did not provide the value.  This is usually caused by not using
| RequestContext.
| 
|   warnings.warn("A {% csrf_token %} was used in a template, but the
|   context did not provide the value.  This is usually caused by not
|   using RequestContext.")
`

I tried step 3.2, instead of step 3.1, because the page above did not
contain enough detail for me to figure out how to use RequestContext and
I was too lazy to type it into the search box: I was suitably punished
for my laziness.

I finally found a different page that described how to use RequestContext:

   
https://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-context-requestcontext

with the following code fragment:

--8<---cut here---start->8---
from django.shortcuts import render_to_response
from django.template import RequestContext

def some_view(request):
# ...
return render_to_response('my_template.html',
  my_data_dictionary,
  context_instance=RequestContext(request))
--8<---cut here---end--->8---

I adapted it for my purposes and things are working fine.

The question is: is the first method supposed to work? If so, what am
I doing wrong? If not, it should be taken out of the documentation.

Also, can a link be added in the first page to get to the second page
easily?

Thanks!
-- 
Nick



-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Fwd: Delivery Status Notification (Failure)

2013-03-11 Thread Nick Dokos
jesmine chaudhuri  wrote:

> Hello,
> 
> I am new in Python and Django. This is my first test project following the
> site :
> 
> https://docs.djangoproject.com/en/1.3/intro/tutorial01/
> 
> I am using database MySQL.
> 
> I configured in
> 
> INSTALLED_APPS = (
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
>     'django.contrib.sites',
>     'polls'
> )
> 
> After that I am trying to run :
> 
> python manage.py sql polls
> 
> But I am getting this error :
> 
> App with label polls could not be found. Are you sure your
> > INSTALLED_APPS setting is correct?
> 

The docs recommend that you add

...
'polls',
  )

with a final comma, but that's only to prevent you from errors if you
add more apps at the end: it should work without the comma if 'polls' is
the final element of the tuple. Nevertheless, you probably want to make
it a habit to add the comma (which btw is necessary for a one-element
tuple - not the case here, but forewarned is forearmed).

Do an ``ls'' in the directory where you do the ``python manage.py sql
polls'': do you have a subdirectory named `polls' with the standard
structure? Below, I have named the project `poll' and the app `polls'
(which is a bit confusing, sorry: I should have named the project
`poll_project' or something). Here's what I get:

,
| $ python manage.py sql polls
| BEGIN;
| CREATE TABLE "polls_poll" (
| "id" integer NOT NULL PRIMARY KEY,
| "question" varchar(200) NOT NULL,
| "pub_date" datetime NOT NULL
| )
| ;
| CREATE TABLE "polls_choice" (
| "id" integer NOT NULL PRIMARY KEY,
| "poll_id" integer NOT NULL REFERENCES "polls_poll" ("id"),
| "choice_text" varchar(200) NOT NULL,
| "votes" integer NOT NULL
| )
| ;
| COMMIT;
| 
| $ ls
| manage.py  poll  pollspolls.db
| 
| $ ls polls
| admin.py  admin.pyc  __init__.py  __init__.pycmodels.py   models.pyc  
tests.py  views.py
`

Nick

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: cannot install django-tracking

2013-03-11 Thread Nick Dokos
frocco  wrote:

> Hello,
> 
> I am getting
> django.core.exceptions.ImproperlyConfigured: Requested setting CACHES, but 
> settings are not
> configured. You must either define the environment variable 
> DJANGO_SETTINGS_MODULE or call
> settings.configure() before accessing settings.
> 
> trying pip install django-tracking
> 
> Does this work in django 1.5?
> 

FWIW, I tried ``pip install django-tracking'' in a virtualenv where I
had installed django 1.4.3 final, and it was successfully installed:


,
| $ pip install django-tracking
| Downloading/unpacking django-tracking
|   Downloading django-tracking-0.4.1.tar.gz (1.9Mb): 1.9Mb downloaded
|   Running setup.py egg_info for package django-tracking
| 
| warning: no previously-included files matching '.*.swp' found under 
directory 'tracking'
| warning: no previously-included files matching '*.*' found under 
directory 'demo'
| Installing collected packages: django-tracking
|   Running setup.py install for django-tracking
| 
| warning: no previously-included files matching '.*.swp' found under 
directory 'tracking'
| warning: no previously-included files matching '*.*' found under 
directory 'demo'
| Successfully installed django-tracking
| Cleaning up...
`

Nick

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Stuck

2012-12-26 Thread Nick Dokos
rktur...@gmail.com wrote:

> I'll keep this as short as possible. When I input  python manage.py sql 
> polls, i get the following
> error:
>  
> C:\Python27\Lib\site-packages\django\bin\mysite>python manage.py sql pol
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py
> 443, in execute_from_command_line
> utility.execute()
>   File "C:\Python27\lib\site-packages\django\core\management\__init__.py
> 382, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "C:\Python27\lib\site-packages\django\core\management\base.py", l
>  in run_from_argv
> self.execute(*args, **options.__dict__)
>   File "C:\Python27\lib\site-packages\django\core\management\base.py", l
>  in execute
> self.validate()
>   File "C:\Python27\lib\site-packages\django\core\management\base.py", l
>  in validate
> num_errors = get_validation_errors(s, app)
>   File "C:\Python27\lib\site-packages\django\core\management\validation.
> e 30, in get_validation_errors
> for (app_name, error) in get_app_errors().items():
>   File "C:\Python27\lib\site-packages\django\db\models\loading.py", line
>  get_app_errors
> self._populate()
>   File "C:\Python27\lib\site-packages\django\db\models\loading.py", line
> _populate
> self.load_app(app_name, True)
>   File "C:\Python27\lib\site-packages\django\db\models\loading.py", line
> load_app
> models = import_module('.models', app_name)
>   File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 3
> port_module
> __import__(name)
>   File "C:\Python27\Lib\site-packages\django\bin\mysite\polls\models.py"
> 0
> votes = models.IntergerField()
>  ^
> IndentationError: unindent does not match any outer indentation level
> 
> So here is my settings.py "Installed apps" 
> 
> INSTALLED_APPS = (
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.sites',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> # Uncomment the next line to enable the admin:
> # 'django.contrib.admin',
> # Uncomment the next line to enable admin documentation:
> # 'django.contrib.admindocs',
> 'polls',
> )
> 
> And here is my models.py:
> 
> from django.db import models
> 
> class Poll(models.Model):
> question = models.CharField(max_length=200)
> pub_date = models.DateTimeField('date published')
> class Choice(models.Model):
> poll = models.ForeignKey(Poll)
> choice = models.CharField(max_length=200)
> votes = models.IntergerField()
> 

In python, indentation matters. Also, spelling matters just as much as
it does in other languages: IntergerField should be IntegerField. Try:

--8<---cut here---start->8---
class Poll(models.Model):
  question = models.CharField(max_length=200)
  pub_date = models.DateTimeField('date published')

class Choice(models.Model):
  poll = models.ForeignKey(Poll)
  choice = models.CharField(max_length=200)
  votes = models.IntegerField()
--8<---cut here---end--->8---

Nick

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: invalid syntax (admin.py, line 25)

2012-10-09 Thread Nick Dokos
Jim Wombles  wrote:

> I'm working through the Django Tutorial: Photo Organizer and Sharing App and 
> I am getting an invalid syntax error in line 25 of admin.py:
> 
> 1st = [x[1] for x in self.tags.values_list()]
> 

Forget django: just go into the python interpreter and say

1st = 3

Same error, right? :-)

Nick

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: i am getting ConfigParser.NoSectionError: No section: 'database' plz help

2012-09-28 Thread Nick Dokos
Laxmikant Gurnalkar  wrote:

> Thats the same I'm saying to you.
> In your settings.conf. There is no section named 'database'

Look again: there *is* a [database] section at the very bottom:

[database]
engine    : django.db.backends.mysql
name  : kasakoo
user  : root
password  : password
host  : localhost
port  : 3306

Nick

> create a section in that file to store your database info.
> Check the file located at :
> os.path.join(PROJECT_PATH, 'settings.conf')
> 
> On Fri, Sep 28, 2012 at 9:50 AM, Navnath Gadakh  
> wrote:
> 
> my setting.py is
>  and a have also created a new setting.conf .may be there is problem of 
> path,plz  help. thnks in
> adv
> # Django settings for kasakooproj project.
>
> import os
> import ast
>
> from ConfigParser import RawConfigParser
>
> config = RawConfigParser()
> PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
> config.read(os.path.join(PROJECT_PATH, 'settings.conf'))
>
> DEBUG = True
> TEMPLATE_DEBUG = DEBUG
> 
> MANAGERS = ADMINS
>
> DATABASES = {
>     'default': {
>     'ENGINE'  : config.get('database','engine'),
>     'NAME'    : config.get('database','name'),
>     'USER'    : config.get('database','user'),
>     'PASSWORD': config.get('database','password'),
>     'HOST'    : config.get('database','host'),
>     'PORT'    : config.get('database','port'), }
> }
>
> # Local time zone for this installation. Choices can be found here:
> # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
> # although not all choices may be available on all operating systems.
> # On Unix systems, a value of None will cause Django to use the same
> # timezone as the operating system.
> # If running in a Windows environment this must be set to the same as your
> # system time zone.
> TIME_ZONE = 'America/Chicago'
>
> # Language code for this installation. All choices can be found here:
> # http://www.i18nguy.com/unicode/language-identifiers.html
> LANGUAGE_CODE = 'en-us'
>
> SITE_ID = 1
>
> # If you set this to False, Django will make some optimizations so as not
> # to load the internationalization machinery.
> USE_I18N = True
>
> # If you set this to False, Django will not format dates, numbers and
> # calendars according to the current locale
> USE_L10N = True
>
> # Absolute filesystem path to the directory that will hold user-uploaded 
> files.
> # Example: "/home/media/media.lawrence.com/media/"
> MEDIA_ROOT = os.path.join(PROJECT_PATH, 'media')
>
> # URL that handles the media served from MEDIA_ROOT. Make sure to use a
> # trailing slash.
> # Examples: "http://media.lawrence.com/media/;, 
> "http://example.com/media/;
> MEDIA_URL = config.get('media_url', 'value')
>
> # Absolute path to the directory static files should be collected to.
> # Don't put anything in this directory yourself; store your static files
> # in apps' "static/" subdirectories and in STATICFILES_DIRS.
> # Example: "/home/media/media.lawrence.com/static/"
> STATIC_ROOT = os.path.join(PROJECT_PATH, 'static')
>
> # URL prefix for static files.
> # Example: "http://media.lawrence.com/static/;
> STATIC_URL = config.get('static_url', 'value')
>
> # URL prefix for admin static files -- CSS, JavaScript and images.
> # Make sure to use a trailing slash.
> # Examples: "http://foo.com/static/admin/;, "/static/admin/".
> ADMIN_MEDIA_PREFIX = '/static/admin/'
>
> # Additional locations of static files
> STATICFILES_DIRS = (
>     # Put strings here, like "/home/html/static" or 
> "C:/www/django/static".
>     # Always use forward slashes, even on Windows.
>     # Don't forget to use absolute paths, not relative paths.
> )
>
> # List of finder classes that know how to find static files in
> # various locations.
> STATICFILES_FINDERS = (
>     'django.contrib.staticfiles.finders.FileSystemFinder',
>     'django.contrib.staticfiles.finders.AppDirectoriesFinder',
> #    'django.contrib.staticfiles.finders.DefaultStorageFinder',
> )
>
> # Make this unique, and don't share it with anybody.
> SECRET_KEY = ''
>
> # List of callables that know how to import templates from various 
> sources.
> TEMPLATE_LOADERS = (
>     'django.template.loaders.filesystem.Loader',
>     'django.template.loaders.app_directories.Loader',
> # 'django.template.loaders.eggs.Loader',
> )
>
> MIDDLEWARE_CLASSES = (
>     'django.middleware.common.CommonMiddleware',
>     'django.contrib.sessions.middleware.SessionMiddleware',
>     'django.middleware.csrf.CsrfViewMiddleware',
>