Re: Can Django partially process a url, then resume?

2013-09-04 Thread rush
Hi,

why not to implement this check in the beginning of your view and if it's 
required just redirect the url to the same view with correct details which will 
just pass initial check?

--
wbr,
rush

05.09.13, 08:51, "KentH" ":
> 
> Hi,
> 
> I've got an app where I'd like to partially process some URLs, and then 
> afterwards have django resume & dispatch.
> 
> Consider the following example: url pattern matches 
> http://www.example.com/location/dept/some/other/info.
> 
> In this example, the location can move (eg: dept relocated). And the dept 
> name can change.
> 
> The obvious (to me) solution is to turn location/dept into a <> 
> ( a non-trivial operation which handles relocations,
> and stores canonical location/dept in session to prevent repeated lookups, 
> etc)  and then process the rest of the url, passing a
> "dept=dept" kwarg. But to do this, I need django to pick up & carry on 
> resolving, with a different URL_ROOT.
> 
> Is this possible?
> 
> Thanks. Kent
> 
> 
> -- 
> 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.

-- 
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.


Can Django partially process a url, then resume?

2013-09-04 Thread KentH
Hi,

I've got an app where I'd like to partially process some URLs, and then 
afterwards have django resume & dispatch.

Consider the following example: url pattern matches 
http://www.example.com/location/dept/some/other/info.

In this example, the location can move (eg: dept relocated). And the dept 
name can change.

The obvious (to me) solution is to turn location/dept into a <> ( a non-trivial operation which handles relocations,
and stores canonical location/dept in session to prevent repeated lookups, 
etc)  and then process the rest of the url, passing a
"dept=dept" kwarg. But to do this, I need django to pick up & carry on 
resolving, with a different URL_ROOT.

Is this possible?

Thanks. Kent

-- 
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.


Django migrate model with user in a foreignkey fails (ValueError: Related model u'auth.User' cannot been resolved)

2013-09-04 Thread Tomas Jacobsen
Im trying to migrate my django model:

from django.contrib.auth.models import User

class Post(models.Model):
headline = models.CharField(max_length=200)
slug = models.SlugField(max_length=200)
body = models.TextField(blank=True, null=True)
author = models.ForeignKey(User, null=True, blank=True)


I added the author field after I created the model.



Here is the migration django creates:

# encoding: utf8
from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [('articles', '0002_auto')]

operations = [
migrations.AddField(
field = models.ForeignKey(to_field=u'id', to=u'auth.User', 
blank=True, null=True),
name = 'author',
model_name = 'post',
),
]
 Here is my traceback when I try to run ./manage.py migrate:


Operations to perform:
  Synchronize unmigrated apps: ckeditor, sessions, admin, messages, auth, 
staticfiles, contenttypes, django_extensions
  Apply all migrations: articles
Synchronizing apps without migrations:
  Creating tables...
  Installing custom SQL...
  Installing indexes...
Installed 0 object(s) from 0 fixture(s)
Running migrations:
  Applying articles.0002_post_author...Traceback (most recent call last):
  File "./manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File 
"/home/USER/.virtualenvs/PROJECT/src/django-trunk/django/core/management/__init__.py",
 
line 397, in execute_from_command_line
utility.execute()
  File 
"/home/USER/.virtualenvs/PROJECT/src/django-trunk/django/core/management/__init__.py",
 
line 390, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/home/USER/.virtualenvs/PROJECT/src/django-trunk/django/core/management/base.py",
 
line 242, in run_from_argv
self.execute(*args, **options.__dict__)
  File 
"/home/USER/.virtualenvs/PROJECT/src/django-trunk/django/core/management/base.py",
 
line 289, in execute
output = self.handle(*args, **options)
  File 
"/home/USER/.virtualenvs/PROJECT/src/django-trunk/django/core/management/commands/migrate.py",
 
line 116, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
  File 
"/home/USER/.virtualenvs/PROJECT/src/django-trunk/django/db/migrations/executor.py",
 
line 60, in migrate
self.apply_migration(migration, fake=fake)
  File 
"/home/USER/.virtualenvs/PROJECT/src/django-trunk/django/db/migrations/executor.py",
 
line 73, in apply_migration
migration.apply(project_state, schema_editor)
  File 
"/home/USER/.virtualenvs/PROJECT/src/django-trunk/django/db/migrations/migration.py",
 
line 80, in apply
operation.database_forwards(self.app_label, schema_editor, 
project_state, new_state)
  File 
"/home/USER/.virtualenvs/PROJECT/src/django-trunk/django/db/migrations/operations/fields.py",
 
line 22, in database_forwards
schema_editor.add_field(from_model, 
to_model._meta.get_field_by_name(self.name)[0])
  File 
"/home/USER/.virtualenvs/PROJECT/src/django-trunk/django/db/backends/schema.py",
 
line 349, in add_field
definition, params = self.column_sql(model, field, include_default=True)
  File 
"/home/USER/.virtualenvs/PROJECT/src/django-trunk/django/db/backends/schema.py",
 
line 105, in column_sql
db_params = field.db_parameters(connection=self.connection)
  File 
"/home/USER/.virtualenvs/PROJECT/src/django-trunk/django/db/models/fields/related.py",
 
line 1285, in db_parameters
return {"type": self.db_type(connection), "check": []}
  File 
"/home/USER/.virtualenvs/PROJECT/src/django-trunk/django/db/models/fields/related.py",
 
line 1276, in db_type
rel_field = self.related_field
  File 
"/home/USER/.virtualenvs/PROJECT/src/django-trunk/django/db/models/fields/related.py",
 
line 1183, in related_field
return self.foreign_related_fields[0]
  File 
"/home/USER/.virtualenvs/PROJECT/src/django-trunk/django/db/models/fields/related.py",
 
line 971, in foreign_related_fields
return tuple(rhs_field for lhs_field, rhs_field in self.related_fields)
  File 
"/home/USER/.virtualenvs/PROJECT/src/django-trunk/django/db/models/fields/related.py",
 
line 958, in related_fields
self._related_fields = self.resolve_related_fields()
  File 
"/home/USER/.virtualenvs/PROJECT/src/django-trunk/django/db/models/fields/related.py",
 
line 943, in resolve_related_fields
raise ValueError('Related model %r cannot been resolved' % self.rel.to)
ValueError: Related model u'auth.User' cannot been resolved


Anyone know what I'm doing wrong? Or is this a bug? (Using 
1.7.dev20130903182221)

-- 
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 

Connection Reset by Peer (104) on POST submission

2013-09-04 Thread Brian Henning
I am trying to deploy my Django site. On my development environment using 
runserver, everything works perfectly. After deploying to production with 
Apache and Passenger WSGI on a shared hosting environment, the majority of 
the site works correctly. However, I am having one issue that I am unable 
to figure out.

When submitting a form via POST with enctype="multipart/form-data" and that 
has filefields or imagefields in the form, I get a connection reset page. 
The apache error log shows the following error:

[Wed Sept 4 17:11:53 2013] [error] [client 123.45.6.78] 
(104)Connection reset by peer: ap_content_length_filter: apr_bucket_read() 
failed, referer: http://www.example.com

Has anyone experienced this error or know how to fix it?

Below is the form file, template and view code that handles the POST 
submission:

< forms.py -->
class TestForm(forms.Form):
name = forms.CharField(label='Last Name', max_length=100)
file = forms.ImageField(required=False)
< end forms.py -->

< test_page.html -->








{% if form %}

{% for field in form %}

{{ field.errors }}
{{ field.label_tag }}: {{ field }}

{% endfor %}
{% csrf_token %}


{% endif %}


<--- end test_page.html ---> 

< views.py ->
from django.template import RequestContext
from forms import TestForm

def test_form_view(request):

if request.method == 'POST':

return render_to_response('test_page.html',{},)

else:
return render_to_response('test_page.html',{ 'form': TestForm(), },
context_instance=RequestContext(request))
< end views.py >

-- 
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.


dictfetchall(cursor) - What kind of sorcery is this?

2013-09-04 Thread Pepsodent Cola
I borrowed the dictfetchall(cursor) code directly from Djangoproject.com 
and it works with my code.
But what kind of sorcery is this?  How can I output the contents of *desc*? 
 I want to see what that data looks like.

*desc* = cursor.description

Because I can't follow what's going on here.

for col in *desc*

#___
https://docs.djangoproject.com/en/1.6/topics/db/sql/#connections-and-cursors

def dictfetchall(cursor):
"Returns all rows from a cursor as a dict."
desc = cursor.description
return [
dict(zip([col[0] for col in desc], row))
for row in cursor.fetchall()
]
#___

class AltwordManager(models.Manager):
def vote_order(self):
"Returns a 1:M list ordered by votes."
cursor =  connection.cursor()
cursor.execute("""
SELECT navi_polls_word.rosword, navi_polls_altword.alt_ros_word, 
navi_polls_altword.votes
FROM navi_polls_altword INNER JOIN navi_polls_word
ON (navi_polls_altword.rosword_id=navi_polls_word.id)
""")
#row = cursor.fetchall()
row = dictfetchall(cursor)
return row
#___

-- 
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: Do I always have to run collectstatic to serve uploaded images by apache?

2013-09-04 Thread Kelvin Wong
The MEDIA_ROOT is the local system location where the FileField in your 
models is going to store incoming files. Users submit files and they are 
placed in the location specified by the 'upload_to' setting of the field 
(usually a directory within MEDIA_ROOT).

https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.upload_to

You should remove your MEDIA_ROOT from STATICFILES_DIRS.

Then you should review this documentation.

https://docs.djangoproject.com/en/dev/topics/http/file-uploads/

The 'collectstatic' command collects your static assets, not user submitted 
content. Your system is misconfigured and that is why it is collecting user 
submitted files.

K


On Wednesday, September 4, 2013 12:41:03 PM UTC-7, Robin Lery wrote:
>
> I have a site, where users can upload images. And it works fine in 
> django's own server. But I am using apache to serve both my app and 
> statics. And when I upload any image, I can't see the pics. Only when I run
> collectstatic I can see them. Do I always have to run collectstatic? Is 
> there any better way to do this?
>
> my settings.py snippet:
>
> MEDIA_ROOT = 'C:/Users/Robin/web/leo/static'
>
> STATIC_ROOT = 'C:/Users/Robin/static/'
>
> STATICFILES_DIRS = (
> "C:/Users/Robin/web/leo/static",
>
>  apache http.cont snippet:
>
> AliasMatch ^/([^/]*\.css) C:/Users/Robin/static/styles/$1
> Alias /static/ C:/Users/Robin/static/
> Order deny,allowAllow from all
> WSGIScriptAlias / C:/Users/Robin/web/leo/leo/wsgi.py
> Order allow,denyAllow 
> from all
>
>  Please guide me. Any help will be appreciated greatly. Thank you!
>

-- 
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: ValueError at / Empty module name

2013-09-04 Thread Kelvin Wong
Your MEDIA_ROOT setting is also suspect.

As-is you will be writing user submitted files into your shared 
site-packages folder. Hopefully you won't be running Django as root and 
you'll get a permission error.

K

-- 
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: dictfetchall(cursor) - What kind of sorcery is this?

2013-09-04 Thread Pepsodent Cola
Thanks for the link I will study it.

But I still would like some help with printing and visualizing that "desc" 
data just to make sure it's not Voodoo.  :)
I don't really know how to print that out, MVC is confusing me.  Can you 
give me a hint which file I need to input my "print desc" LOC?

models.py , views.py or my html template file?






On Wednesday, September 4, 2013 9:55:13 PM UTC+2, Pepsodent Cola wrote:
>
> I borrowed the dictfetchall(cursor) code directly from Djangoproject.com 
> and it works with my code.
> But what kind of sorcery is this?  How can I output the contents of *desc*? 
>  I want to see what that data looks like.
>
> *desc* = cursor.description
>
> Because I can't follow what's going on here.
>
> for col in *desc*
>
>
> #___
>
> https://docs.djangoproject.com/en/1.6/topics/db/sql/#connections-and-cursors
>
> def dictfetchall(cursor):
> "Returns all rows from a cursor as a dict."
> desc = cursor.description
> return [
> dict(zip([col[0] for col in desc], row))
> for row in cursor.fetchall()
> ]
>
> #___
>
> class AltwordManager(models.Manager):
> def vote_order(self):
> "Returns a 1:M list ordered by votes."
> cursor =  connection.cursor()
> cursor.execute("""
> SELECT navi_polls_word.rosword, navi_polls_altword.alt_ros_word, 
> navi_polls_altword.votes
> FROM navi_polls_altword INNER JOIN navi_polls_word
> ON (navi_polls_altword.rosword_id=navi_polls_word.id)
> """)
> #row = cursor.fetchall()
> row = dictfetchall(cursor)
> return row
>
> #___
>
>

-- 
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: dictfetchall(cursor) - What kind of sorcery is this?

2013-09-04 Thread Masklinn

On 2013-09-04, at 21:55 , Pepsodent Cola wrote:

> I borrowed the dictfetchall(cursor) code directly from Djangoproject.com 
> and it works with my code.
> But what kind of sorcery is this?  How can I output the contents of *desc*? 
> I want to see what that data looks like.
> 
>*desc* = cursor.description

Have you tried just printing it out?

Not that you need to,
http://www.python.org/dev/peps/pep-0249/#description will tell you what
`cursor.description` is.

-- 
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.


Do I always have to run collectstatic to serve uploaded images by apache?

2013-09-04 Thread Robin Lery
I have a site, where users can upload images. And it works fine in django's
own server. But I am using apache to serve both my app and statics. And
when I upload any image, I can't see the pics. Only when I runcollectstatic I
can see them. Do I always have to run collectstatic? Is there any better
way to do this?

my settings.py snippet:

MEDIA_ROOT = 'C:/Users/Robin/web/leo/static'

STATIC_ROOT = 'C:/Users/Robin/static/'

STATICFILES_DIRS = (
"C:/Users/Robin/web/leo/static",

apache http.cont snippet:

AliasMatch ^/([^/]*\.css) C:/Users/Robin/static/styles/$1
Alias /static/ C:/Users/Robin/static/
Order deny,allowAllow from all
WSGIScriptAlias / C:/Users/Robin/web/leo/leo/wsgi.py
Order
allow,denyAllow from all

Please guide me. Any help will be appreciated greatly. Thank you!

-- 
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: Prefork vs threaded when I want to spawn my own threads

2013-09-04 Thread Andre Terra
On Wed, Sep 4, 2013 at 2:36 PM, Javier Guerra Giraldez
wrote:

> above that, Redis is a clean, fast and very scalable platform for
> queues.  if you don't have heavy buzzword dependency, i wouldn't
> bother checking AMQP systems and stay with Redis.
>

A thousand times this. You don't need AMQP systems until you need them.

-- 
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: ValueError at / Empty module name

2013-09-04 Thread Satinderpal Singh
On Wed, Sep 4, 2013 at 11:28 PM, Mantas Zilinskis
 wrote:
> your problem is in TEMPLATE_CONTEXT_PROCESSORS = (
> 'django.contrib.messages.context_processors.messages'
> 'django.contrib.auth.context_processors.auth'
> )
> it's a tuple, you have to have a comma after messages proccesor

Thanks a lot Mantas.

>
> On Wed, Sep 4, 2013 at 12:53 PM, Mantas Zilinskis
>  wrote:
>>
>> and also all your traceback
>>
>>
>> On Wed, Sep 4, 2013 at 12:45 PM, Satinderpal Singh
>>  wrote:
>>>
>>> On Wed, Sep 4, 2013 at 11:11 PM, Mantas Zilinskis
>>>  wrote:
>>> > can you post your settings.py
>>>
>>> Here it is:
>>>
>>> # Django settings for nanaksar project.
>>>
>>> DEBUG = True
>>> TEMPLATE_DEBUG = DEBUG
>>>
>>> ADMINS = (
>>> # ('Your Name', 'your_em...@example.com'),
>>> )
>>>
>>> MANAGERS = ADMINS
>>>
>>> DATABASES = {
>>> 'default': {
>>> 'ENGINE': 'django.db.backends.mysql', # Add
>>> 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
>>> 'NAME': 'babaji',  # Or path to database
>>> file if using sqlite3.
>>> 'USER': '***',  # Not used with sqlite3.
>>> 'PASSWORD': '***',  # Not used with sqlite3.
>>> 'HOST': '',  # Set to empty string for
>>> localhost. Not used with sqlite3.
>>> 'PORT': '',  # Set to empty string for
>>> default. Not used with sqlite3.
>>> }
>>> }
>>>
>>> # 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
>>>
>>> # If you set this to False, Django will not use timezone-aware datetimes.
>>> USE_TZ = True
>>>
>>> # Absolute filesystem path to the directory that will hold user-uploaded
>>> files.
>>> # Example: "/home/media/media.lawrence.com/media/"
>>> MEDIA_ROOT =
>>> '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/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 = '/media/'
>>>
>>> LOCAL_URL = 'http://localhost/'
>>>
>>> # 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 = ''
>>>
>>> # URL prefix for static files.
>>> # Example: "http://media.lawrence.com/static/;
>>> STATIC_URL = '/static/'
>>>
>>> # Additional locations of static files
>>> STATICFILES_DIRS = ('/home/goraya/nanaksar/templates',
>>> # 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 = '%q_rpw9rkr8wi2gjno5ap7k)1j%4rpe(eisczh5zw%dlpa$h6@'
>>>
>>> # 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',
>>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>>> 'django.contrib.messages.middleware.MessageMiddleware',
>>> # Uncomment the next line for simple clickjacking protection:
>>> # 

Re: ValueError at / Empty module name

2013-09-04 Thread Satinderpal Singh
On Wed, Sep 4, 2013 at 11:23 PM, Mantas Zilinskis
 wrote:
> and also all your traceback

Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py"
in get_response
  140. response = response.render()
File "/usr/local/lib/python2.7/dist-packages/django/template/response.py"
in render
  105. self.content = self.rendered_content
File "/usr/local/lib/python2.7/dist-packages/django/template/response.py"
in rendered_content
  81. context = self.resolve_context(self.context_data)
File "/usr/local/lib/python2.7/dist-packages/django/template/response.py"
in resolve_context
  159. return RequestContext(self._request, context,
current_app=self._current_app)
File "/usr/local/lib/python2.7/dist-packages/django/template/context.py"
in __init__
  178. for processor in get_standard_processors() + processors:
File "/usr/local/lib/python2.7/dist-packages/django/template/context.py"
in get_standard_processors
  152. mod = import_module(module)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py"
in import_module
  35. __import__(name)

Exception Type: ValueError at /
Exception Value: Empty module name

-- 
Satinderpal Singh

-- 
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: ValueError at / Empty module name

2013-09-04 Thread Mantas Zilinskis
your problem is in TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.messages.context_processors.messages'
'django.contrib.auth.context_processors.auth'
)
it's a tuple, you have to have a comma after messages proccesor


On Wed, Sep 4, 2013 at 12:53 PM, Mantas Zilinskis  wrote:

> and also all your traceback
>
>
> On Wed, Sep 4, 2013 at 12:45 PM, Satinderpal Singh <
> satinder.goray...@gmail.com> wrote:
>
>> On Wed, Sep 4, 2013 at 11:11 PM, Mantas Zilinskis
>>  wrote:
>> > can you post your settings.py
>>
>> Here it is:
>>
>> # Django settings for nanaksar project.
>>
>> DEBUG = True
>> TEMPLATE_DEBUG = DEBUG
>>
>> ADMINS = (
>> # ('Your Name', 'your_em...@example.com'),
>> )
>>
>> MANAGERS = ADMINS
>>
>> DATABASES = {
>> 'default': {
>> 'ENGINE': 'django.db.backends.mysql', # Add
>> 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
>> 'NAME': 'babaji',  # Or path to database
>> file if using sqlite3.
>> 'USER': '***',  # Not used with sqlite3.
>> 'PASSWORD': '***',  # Not used with sqlite3.
>> 'HOST': '',  # Set to empty string for
>> localhost. Not used with sqlite3.
>> 'PORT': '',  # Set to empty string for
>> default. Not used with sqlite3.
>> }
>> }
>>
>> # 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
>>
>> # If you set this to False, Django will not use timezone-aware datetimes.
>> USE_TZ = True
>>
>> # Absolute filesystem path to the directory that will hold user-uploaded
>> files.
>> # Example: "/home/media/media.lawrence.com/media/"
>> MEDIA_ROOT =
>> '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/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 = '/media/'
>>
>> LOCAL_URL = 'http://localhost/'
>>
>> # 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 = ''
>>
>> # URL prefix for static files.
>> # Example: "http://media.lawrence.com/static/;
>> STATIC_URL = '/static/'
>>
>> # Additional locations of static files
>> STATICFILES_DIRS = ('/home/goraya/nanaksar/templates',
>> # 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 = '%q_rpw9rkr8wi2gjno5ap7k)1j%4rpe(eisczh5zw%dlpa$h6@'
>>
>> # 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',
>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>> 'django.contrib.messages.middleware.MessageMiddleware',
>> # Uncomment the next line for simple clickjacking protection:
>> # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
>> )
>>
>> TEMPLATE_CONTEXT_PROCESSORS = (
>> 'django.contrib.messages.context_processors.messages'
>> 'django.contrib.auth.context_processors.auth'
>> )
>>
>> ROOT_URLCONF = 'nanaksar.urls'
>>
>> # Python dotted path 

Re: ValueError at / Empty module name

2013-09-04 Thread Mantas Zilinskis
and also all your traceback


On Wed, Sep 4, 2013 at 12:45 PM, Satinderpal Singh <
satinder.goray...@gmail.com> wrote:

> On Wed, Sep 4, 2013 at 11:11 PM, Mantas Zilinskis
>  wrote:
> > can you post your settings.py
>
> Here it is:
>
> # Django settings for nanaksar project.
>
> DEBUG = True
> TEMPLATE_DEBUG = DEBUG
>
> ADMINS = (
> # ('Your Name', 'your_em...@example.com'),
> )
>
> MANAGERS = ADMINS
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.mysql', # Add
> 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
> 'NAME': 'babaji',  # Or path to database
> file if using sqlite3.
> 'USER': '***',  # Not used with sqlite3.
> 'PASSWORD': '***',  # Not used with sqlite3.
> 'HOST': '',  # Set to empty string for
> localhost. Not used with sqlite3.
> 'PORT': '',  # Set to empty string for
> default. Not used with sqlite3.
> }
> }
>
> # 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
>
> # If you set this to False, Django will not use timezone-aware datetimes.
> USE_TZ = True
>
> # Absolute filesystem path to the directory that will hold user-uploaded
> files.
> # Example: "/home/media/media.lawrence.com/media/"
> MEDIA_ROOT =
> '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/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 = '/media/'
>
> LOCAL_URL = 'http://localhost/'
>
> # 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 = ''
>
> # URL prefix for static files.
> # Example: "http://media.lawrence.com/static/;
> STATIC_URL = '/static/'
>
> # Additional locations of static files
> STATICFILES_DIRS = ('/home/goraya/nanaksar/templates',
> # 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 = '%q_rpw9rkr8wi2gjno5ap7k)1j%4rpe(eisczh5zw%dlpa$h6@'
>
> # 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',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> # Uncomment the next line for simple clickjacking protection:
> # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> )
>
> TEMPLATE_CONTEXT_PROCESSORS = (
> 'django.contrib.messages.context_processors.messages'
> 'django.contrib.auth.context_processors.auth'
> )
>
> ROOT_URLCONF = 'nanaksar.urls'
>
> # Python dotted path to the WSGI application used by Django's runserver.
> WSGI_APPLICATION = 'nanaksar.wsgi.application'
>
> TEMPLATE_DIRS = ("/home/goraya/nanaksar/templates"
> # Put strings here, like "/home/html/django_templates" or
> "C:/www/django/templates".
> # Always use forward slashes, even on Windows.
> # Don't forget to use absolute paths, not relative paths.
> )
>
> INSTALLED_APPS = (
> 'django.contrib.auth',
> 

Re: ValueError at / Empty module name

2013-09-04 Thread Satinderpal Singh
On Wed, Sep 4, 2013 at 11:11 PM, Mantas Zilinskis
 wrote:
> can you post your settings.py

Here it is:

# Django settings for nanaksar project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_em...@example.com'),
)

MANAGERS = ADMINS

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add
'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'babaji',  # Or path to database
file if using sqlite3.
'USER': '***',  # Not used with sqlite3.
'PASSWORD': '***',  # Not used with sqlite3.
'HOST': '',  # Set to empty string for
localhost. Not used with sqlite3.
'PORT': '',  # Set to empty string for
default. Not used with sqlite3.
}
}

# 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

# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = 
'/usr/local/lib/python2.7/dist-packages/django/contrib/admin/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 = '/media/'

LOCAL_URL = 'http://localhost/'

# 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 = ''

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/;
STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = ('/home/goraya/nanaksar/templates',
# 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 = '%q_rpw9rkr8wi2gjno5ap7k)1j%4rpe(eisczh5zw%dlpa$h6@'

# 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',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.messages.context_processors.messages'
'django.contrib.auth.context_processors.auth'
)

ROOT_URLCONF = 'nanaksar.urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'nanaksar.wsgi.application'

TEMPLATE_DIRS = ("/home/goraya/nanaksar/templates"
# Put strings here, like "/home/html/django_templates" or
"C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

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',
'sehra',
)

# A sample logging configuration. The only 

Re: ValueError at / Empty module name

2013-09-04 Thread Mantas Zilinskis
can you post your settings.py


On Wed, Sep 4, 2013 at 12:26 PM, Satinderpal Singh <
satinder.goray...@gmail.com> wrote:

> I face this error after configuring admin.py file in my project:
>
> ValueError at /
>
> Empty module name
>
> Request Method:GET
> Request URL:http://localhost/nanaksar/
> Django Version:1.5.2
> Exception Type:ValueError
> Exception Value:
>
> Empty module name
>
> Exception
> Location:/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py
> in import_module, line 35
> Python Executable:/usr/bin/python
> Python Version:2.7.3
>
> How could i solve this?
>
> --
> Satinderpal Singh
>
> --
> 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.
>

-- 
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: Prefork vs threaded when I want to spawn my own threads

2013-09-04 Thread Javier Guerra Giraldez
On Wed, Sep 4, 2013 at 12:28 PM,   wrote:
> What were people using back in PHP days, cron all the way?


MQs have existed for a long time; but weren't so popular.  I think the
Twitter problems were the wake-up call for most people.

in part because ghetto queues do work, and work well up to a point.
when you grow past its capacity it gets ugly, but below that it's a
real solution.   As first estimate, on anything that gets less than a
hundred tasks a minute, I wouldn't feel bad about using them.

above that, Redis is a clean, fast and very scalable platform for
queues.  if you don't have heavy buzzword dependency, i wouldn't
bother checking AMQP systems and stay with Redis.

-- 
Javier

-- 
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: Prefork vs threaded when I want to spawn my own threads

2013-09-04 Thread mailbox . tec
On 3 september 2013 15:25:42 UTC+2 Russell Keith-Magee wrote:
>
>
> On Tue, Sep 3, 2013 at 9:50 PM,  wrote:
>
>> In my Django application I need to schedule some tasks to run in future. 
>> Celery is not an option here because some crucial options - mainly, the 
>> ability to revoke() a task - are only available with fully-featured MQ 
>> backend and I only have a limited shared hosting where I can't install this 
>> kind of software. After some reading, I've found that supposedly "right" 
>> way to do that in Python is to spawn a subprocess and call sleep(). 
>> However, spawning a process does have an overhead, especially considering a 
>> rather simple nature of tasks I want to defer (retrieval and conditional 
>> deletion of one object).
>>
>> Then I decided to use threads instead. They have little to no overhead, 
>> share memory and Python has a nice little threading.Timer class which is 
>> exactly what I need. My code looks like this:
>>
>> http://pastebin.com/K6RukAX9
>>
>> Here's when my questions come in. I admit my knowledge of threading is 
>> somewhat low and Python operates on high-level too, so nuances are not 
>> easily noticeable. From what I've learned, threads (can?) share memory with 
>> main thread/process. My primary concern here is that, as far as I 
>> understand, method=prefork (the default) creates a pool of processes 
>> waiting for work. It seems possible that it may impact my scheduler 
>> somehow, i.e. if process that spawned it sits idle (sleeps?) when countdown 
>> ends.
>>
>> On the other hand, threaded mode is supposedly more efficient because, 
>> being free from overhead of process forking, it can create child threads at 
>> will. In my mind this raises a similar concern to above: what if framework 
>> decides to destroy a thread that happens to be the one where Timer has been 
>> previously spawned?
>>
>> It is entirely possible that my concerns are completely baseless and both 
>> methods have nothing to do with my scheduler. I'm asking for input from 
>> smarter people than me :)
>>
>  
> Lets back up a bit here. 
>
> Web servers aren't designed to do the sort of thing you're describing. Web 
> requests are not designed to be long lived, and web servers are tuned with 
> this in mind. If you try to make them long lived, you're going to hit all 
> sorts of problems with thread/process lifecycle management. 
>
> The solution here isn't to try and make a web server do something it 
> wasn't designed to do. The solution is to work out how to get a task queue 
> working on your hardware setup.
>
> You say you can't install a fully-fledged MQ service. Ok - that's fine -- 
> but don't throw out the baby with the bathwater. There are other ways to 
> back Celery -- if need be, you can use a database as your data store.
>
> Or, you could consider using an entirely different task queue. If your 
> service provider will give you access to Redis, look into RQ. It's 
> lightweight, but 
>
> Or, if neither of those are viable, you can do a "ghetto queue" -- a 
> combination of cron and a database can be used to implement task queue-like 
> behaviour, without any need for celery.
>
> It's difficult to give more specific advice without knowing the specifics 
> of your problem domain and your deployment options -- but I implore you -- 
> don't keep down the path you're on. That way leads to madness :-)
>
> Yours,
> Russ Magee %-)
>

I get the overall message. I would use threads because that method looks 
simple enough, but if it isn't - I won't insist on it.

Regarding Celery, I was specifically referring to revoke() method, it's 
absolutely crucial for me to be able to revoke a scheduled task. Internet 
says it's only supported with AMQP and Redis ( 
http://stackoverflow.com/questions/7415657/celery-tasks-dont-get-revoked ) 
though now that I look at it, docs also claim compatibility with MongoDB. 
However, I didn't managed to get it to work on such a setup and complete 
lack of error messages didn't help (the call just fails silently).

I don't have Redis on my host, but I guess a free 20 MB instance on a cloud 
will be enough for my needs, so I'll settle with one of these small-ish 
queuers. On a side note, I am a bit surprised that every sane method to do 
scheduled task execution depends on MQs or Redis. Those are fairly new 
tools while the problem definitely didn't appear yesterday. What were 
people using back in PHP days, cron all the way?

Thank you very much for your remarks :)

-- 
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.


ValueError at / Empty module name

2013-09-04 Thread Satinderpal Singh
I face this error after configuring admin.py file in my project:

ValueError at /

Empty module name

Request Method:GET
Request URL:http://localhost/nanaksar/
Django Version:1.5.2
Exception Type:ValueError
Exception Value:

Empty module name

Exception 
Location:/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py
in import_module, line 35
Python Executable:/usr/bin/python
Python Version:2.7.3

How could i solve this?

-- 
Satinderpal Singh

-- 
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: ValueError: Cannot create form field for 'room_setup' yet, because its related model 'main_page.roomsetup' has not been loaded yet

2013-09-04 Thread DJ-Tom
I have now separated the form definitions into forms.py and import the 
models from models.py... so this is fixed

-- 
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: pattern matching wrong app ???

2013-09-04 Thread mmrs151
I would remove the first url and see if it is still taking me to demoproj.

On Tuesday, 3 September 2013 14:18:49 UTC+1, bab mis wrote:
>
> I have 2 app inside my django project:
>
> url(r'^demoproj/$',  include('demoproj.urls')),
>
> url(r'^sample/$',  include('sample.urls')),
>
>
> XX84/sample always redirects to demoproj. Any idea why???
>

-- 
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: pattern matching wrong app ???

2013-09-04 Thread pa xapy
you shouldn't use "$" in the include patterns
>
>

-- 
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: pattern matching wrong app ???

2013-09-04 Thread DJ-Tom

did you try XX84/sample*/* (trailing "/")?

You might also get more answers if you show the content of "demoproj.urls" 
and "sample.urls"

Am Dienstag, 3. September 2013 15:18:49 UTC+2 schrieb bab mis:
>
> I have 2 app inside my django project:
>
> url(r'^demoproj/$',  include('demoproj.urls')),
>
> url(r'^sample/$',  include('sample.urls')),
>
>
> XX84/sample always redirects to demoproj. Any idea why???
>

-- 
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.


ValueError: Cannot create form field for 'room_setup' yet, because its related model 'main_page.roomsetup' has not been loaded yet

2013-09-04 Thread DJ-Tom
Hi,

given the following models and model form I get the error in the subject, 
apparently because the related model "roomsetup" is defined *after* the 
"RoomsForm" form and is not loaded at the time the form is created.

class rooms(models.Model):
[ lots of other fields]
*room_setup* = models.ForeignKey('roomsetup', verbose_name='Room 
setup', blank=False, default='')

def __unicode__(self):
return self.name


class RoomsForm(ModelForm):
class Meta:
model = rooms
fields = ('active', 'location', 'level', *'room_setup'*, 'name', 
'daylight', 'area', 'height', 'notes',)

 other models and forms...

class roomsetup(models.Model):
[lots of fields]

def __unicode__(self):
return self.name

If I move the RoomsForm declaration *below* the room setup class, 
everything works fine, but I would like to keep the model and its 
associated form together in my code (this makes sense?).

So is there another  way how can I avoid this situation?

Thanks 
Thomas 

-- 
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: duplicate entry in django

2013-09-04 Thread Babatunde Akinyanmi
This is usually a side effect of not doing a redirect from the view
that handles your submitted form.

Sent from my Windows Phone
From: Harjot Mann
Sent: 9/4/2013 5:31 AM
To: django-users@googlegroups.com
Subject: duplicate entry in django
In my app whenever the page is refreshed, the double entry is done in
database. I have faced this many times. What should I do to prevent
the multiple entries in database?

-- 
Harjot Kaur Mann
Blog: http://harjotmann.wordpress.com/
Daily Dairy: http://harjotmann.wordpress.com/daily-diary/

-- 
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.

-- 
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.