DateTime field when using django-crispy-form

2013-01-03 Thread Subodh Nijsure
Hello,

Sorry if this should go to some crispy-form specific mailing list. If there
is such thing kindly redirect me towards it.

I am using django-crispy-form to render my forms one thing which I haven't
been able to do is display columns that are of data-time format with some
kind of calender picker.

I have tried the examples out there that use bootstrap-datepicker

(which is only date picker but not time picker). Is there an example out
there how one can display colum that is of type DateTimeField?


-Subodh

-- 
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: django_nose failing to discover tests

2013-01-03 Thread eculver
I think the trick is in the name of the module and/or test case. I can't 
remember exactly how django-nose modifies test discovery but here's what 
nose does alone:

https://nose.readthedocs.org/en/latest/finding_tests.html

Try renaming the test class to something that begins with "Test" -- so like 
"TestAccounts" and then use "test_something", "test_something_else" types 
of names for methods. I think that this should work.

If all else fails, you can always point to the module directly:

./manage.py test myproject.accounts.tests.test_account.AccountTest

You may also try adding '--all-modules' to NOSE_ARGS in your project 
settings:

NOSE_ARGS = [
...
'--all-modules'
]

or by passing "--all-modules" directly to ./manage.py:

./manage.py test --all-modules

Hope this helps.

--Evan


On Monday, December 31, 2012 9:41:33 AM UTC-8, Joe Legner wrote:
>
> I am trying to get django_nose to discover tests in my project.  I watched 
> this video which seems to indicate that my project/app/tests/__init__.py 
> should be able to be empty (not contain a bunch of import * statements):
>
> http://pyvideo.org/video/1406/djangos-nasal-passage
>
> The goal is to have django_nose find my tests by name so I do not have to 
> have import * from ... statements within my tests/__init__.py for every 
> app.  My project is set up like this:
>
> /myproject
> /accounts
> __init__.py
> /tests
> __init__.py
> test_account.py
>
> The __init__.py file is empty.  The test_account.py file contains an 
> AccountTest class derived from unittest.TestCase.
>
> When I run ./manage.py test accounts (with an empty __init__.py), the 
> result is "Ran 0 tests in 0.000s"
>
> Now, if I make accounts/tests/__init__.py contain the line from 
> test_account import *, it works correctly; therefore, I believe I do have 
> django_nose (version 1.1 and nose 1.2.1) installed and working.
>
> I Googled all morning to solve the problem but have failed.  If you have 
> any insight, please reply.  Thank you.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/GUuMIl4BjwMJ.
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: Admin page not found error

2013-01-03 Thread eculver
Hi,

I have ran into this a few times and it's not exactly obvious what's going 
on. In short, the last line of the exception:

return getpass.getuser().decode(locale.getdefaultlocale()[1])

is somewhat of a hint, if you can even call it that. 

Try setting $LANG in your shell environment. For example, if you're using 
bash/zsh:

export LANG=en_US.UTF-8

For other shells, you may have to use setenv.

That's obviously for US english. You'll have to replace "en_US.UTF-8" with 
your locale string. For more information on that check out:

http://cygwin.com/cygwin-ug-net/setup-locale.html
http://userguide.icu-project.org/locale

or you could even check out the man page:

man locale

Hope this helps.

-Evan



On Friday, December 28, 2012 12:29:50 AM UTC-8, Shahjalal Hossain wrote:
>
>
> 
>
>
> 
>
>
> 
>
> Hi, I am new at Django. I am learning Django from instruction manual "a 
> basic poll application". I was doing step by step. But, at a certain point 
> I stacked. 
>
> It does not shows admin page as "2.4 Writing your first Django app, part 
> 2". I have done all the steps, like uncomment settings.py and urls.py and 
> run the syncdb. I am writing on code on Aptana Studio 3. For convenient, I 
> have given some images. and source files.
>
> Thanks, in advance.
>
> *settings.py*
>
> 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',
> )
>
> *urls.py*
>
> from django.conf.urls import patterns, include, url
>
> # Uncomment the next two lines to enable the admin:
> from django.contrib import admin 
> admin.autodiscover()
>
> urlpatterns = patterns('',
> # Examples:
> # url(r'^$', 'mysite.views.home', name='home'),
> # url(r'^mysite/', include('mysite.foo.urls')),
>
> # Uncomment the admin/doc line below to enable admin documentation:
> # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
> # Uncomment the next line to enable the admin:
> url(r'^admin/', include(admin.site.urls)),
> )
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/hEYZPvLCFLMJ.
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.



Django Praise: vs CakePHP

2013-01-03 Thread Kristofer
I just wanted to drop a little praise to everyone who has contributed to Django 
over the years. 

I worked on a project about a year ago, and did it exclusively in CakePHP. I 
can't go into too many details about what the project is due to privacy 
concerns, but it revolved around customer self-service booking for events. This 
included a very long form that was broken out into several steps. 

The customer has asked for quite a few changes as of recently, and the CakePHP 
app is becoming unmanageable and too time consuming to update. 

Over the past few days I took a stab at rewriting it in Django. It was pretty 
easy to copy over the templates and adjust them to the syntax that Django 
expects. I changed around the models a little, and modifications since then 
have been incredibly easy thanks to using South. It makes going from 
development to production a breeze. 

In addition to that, the auto-admin interface has been incredible. It "just 
works". There are a few minor things that have needed tweaking, but it's been 
fast and easy to do. When I update a model with a new attribute, they 
automatically show up (unlike Cake). 

Finally, the FormWizard is incredible. I can't even begin to mention how much 
time I wasted writing my own for this particular project. 

I didn't mention all of the external apps I've included, but they have sure 
made my life a heck of a lot easier. 

Thanks again to everyone who has put time and effort into making Django a great 
framework. My first project with it has made everything much easier, and I 
can't praise it enough. 

Kris 

-- 
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: Django won't send 500 or 404 emails, but django.core.mail.EmailMessage and django.utils.log.AdminEmailHandler work

2013-01-03 Thread Jan Paricka
Same problem here.

1) CommonMiddleware in place

2) debug = False

3) SEND_BROKEN_LINK_EMAILS = True

And yet no 404 emails...

Otherwise the app is happily emailing...

Any thoughts?

Thanks

Jan


On Friday, June 24, 2011 9:56:23 PM UTC+2, Kyle Gong wrote:
>
> For some reason, I can't get my server to send 500 or 404 emails.  I 
> am set up to send email through gmail, and it is working properly when 
> I send error emails through a logger set up using 
> django.utils.log.AdminEmailHandler, and also when I send mail using 
> django.core.mail.EmailMessage. 
>
> I have DEBUG = False and SEND_BROKEN_LINK_EMAILS = True. 
>
> The server is a linode running Ubuntu 10.04, Django 1.3 and Python 
> 2.6.5. 
>
> Any idea where I could look to track down the problem?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/IBt4bGCTyUkJ.
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: Django app custom settings testing

2013-01-03 Thread Pedro J. Aramburu
No, you're not, but, there isn't a way to load or inject the app settings
so that diffsettings and other project level things (like testing) can see
them? That's my question. I've read something on a github repo but it seems
clunky and over-done. My main goal really is to change some settings on the
tests so I can test different scenarios.

Right now it seems I can do it by manually changing the "constants"
importing app.settings, saving the old values, assigning new values and
restoring at the end. But, as the settings.py is loaded once, the
"validation" is also done once (the ImproperlyConfigured part).

Now, my new question: If I do an object Settings or something like that,
and set the __getattr__ to "dinamically" get the settings of the project
settings and if it's not there default to a setting of the same object,
then I should be able to change the settings with
"@override_settings(SETTING_A=True)" or "with
self.settings(SETTING_A=True):".

And, for example, on the explicit case of SETTING_B that depends on
SETTING_A, I could override it's getter (and setter maybe) so I could raise
the exceptions if needed. The thing is, I know __get__ descriptor has
"priority" over "__getattr__" but on the same class (or object). If i use
the @property decorator I will still have "precedence" over getattr? Since
I'm applying it's __get__ descriptor to an object inside.

Just want to know if my approach would work. As I see it, it's like lazy
loading the settings so if the settings change in the project environment,
they should also change in the app. Or something like that is what I'm
trying to do.

What do you think? What would you do?

Thank you.

--
Tres42
Pedro J. Aramburu


On Thu, Jan 3, 2013 at 3:37 PM, Bill Freeman  wrote:

> This approach is only useful for modules that import app.settings and use
> things that it defines.  It doesn't affect things that import settings from
> django.conf .
>
> Your app can import settings from app, and get your settings.  That's not
> going to affect any other app.  If you want to affect what other apps see,
> you must either put the settings in the main settings file, or modify
> django.conf.settings itself.  This last is fraught with peril, since you
> can't reliably control the order in which you modify the settings object
> versus when other modules may use its values in a persistent way.
>
> Or am I missing your point?
>
> Bill
>
>
> On Thu, Jan 3, 2013 at 12:05 AM, Pedro J. Aramburu <
> paramb...@tres42.com.ar> wrote:
>
>> Hi, I'm having troubles using the override_settings decorator. The thing
>> is I'm writing an app that has it's own settings and I'm doing it with the
>> approach of putting a settings.py file on the app folder with something
>> like this:
>>
>> from django.conf import settings
>> from django.core.exceptions import ImproperlyConfigured
>>
>>
>> SETTING_A = getattr(settings, 'APP_SETTING_A', False)
>>
>> SETTING_B = getattr(settings, 'APP_SETTING_B', False)
>>
>> if SETTING_A and not SETTING_B:
>> raise ImproperlyConfigured('"SETTING_A" is set to True but
>> "SETTING_B" is missing.')
>> -
>> Where SETTING_B should be a tuple that depends on SETTING_A (I know I
>> didn't type check yet). Then I use the settings importing app.settings. The
>> thing is, I believe, that the settings are loaded once and as they're
>> outside the project settings.py, override settings doesn't have any effect.
>>
>> What would you recommend?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/django-users/-/22xrwU84AG8J.
>> 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.
>>
>
>  --
> 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.
>

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



Run Individual doctest in model.py or views.py

2013-01-03 Thread Bernard Kuehlhorn
In https://docs.djangoproject.com/en/1.4/topics/testing/ , individual tests 
can be run. It works well for unit tests in tests.py. It should work for 
doctest in model.py. I can not understand how to specify a doctest.

$ ./manage.py test animals.classify


Thanks,
ben

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ULVhlDLwLVwJ.
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.



Django admin save error: get_db_prep_value() got an unexpected keyword argument 'connection'

2013-01-03 Thread Glyn Jackson
I really struggling with my understanding of the following issue and how to 
resolve 





When I try and save (using the Django standard admin interface) I get the 
following error... 

TypeError at /admin/web/campaign/dc6eb21f-87fa-462f-88af-416cf6be37f6/
> 
> get_db_prep_value() got an unexpected keyword argument 'connection'
>

Could someone explain this to me, why and maybe a possible solution? I'm 
assuming it is something to do with my custom HibernateBooleanField field. 

Full error and details below. 

**Error**


Environment:
> 
> 
> Request Method: POST
> Request URL: 
> http://127.0.0.1:8000/admin/web/campaign/dc6eb21f-87fa-462f-88af-416cf6be37f6/
> 
> Django Version: 1.4.2
> Python Version: 2.7.2
> Installed Applications:
> ('django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'django.contrib.flatpages',
>  'django.contrib.messages',
>  'django.contrib.staticfiles',
>  'grappelli.dashboard',
>  'grappelli',
>  'django.contrib.admin',
>  'django.contrib.admindocs',
>  'web')
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware')
> 
> 
> Traceback:
> File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" 
> in get_response
>   111. response = callback(request, 
> *callback_args, **callback_kwargs)
> File 
> "/Library/Python/2.7/site-packages/django/contrib/admin/options.py" in 
> wrapper
>   366. return self.admin_site.admin_view(view)(*args, 
> **kwargs)
> File "/Library/Python/2.7/site-packages/django/utils/decorators.py" in 
> _wrapped_view
>   91. response = view_func(request, *args, 
> **kwargs)
> File 
> "/Library/Python/2.7/site-packages/django/views/decorators/cache.py" in 
> _wrapped_view_func
>   89. response = view_func(request, *args, **kwargs)
> File "/Library/Python/2.7/site-packages/django/contrib/admin/sites.py" 
> in inner
>   196. return view(request, *args, **kwargs)
> File "/Library/Python/2.7/site-packages/django/utils/decorators.py" in 
> _wrapper
>   25. return bound_func(*args, **kwargs)
> File "/Library/Python/2.7/site-packages/django/utils/decorators.py" in 
> _wrapped_view
>   91. response = view_func(request, *args, 
> **kwargs)
> File "/Library/Python/2.7/site-packages/django/utils/decorators.py" in 
> bound_func
>   21. return func(self, *args2, **kwargs2)
> File "/Library/Python/2.7/site-packages/django/db/transaction.py" in 
> inner
>   209. return func(*args, **kwargs)
> File 
> "/Library/Python/2.7/site-packages/django/contrib/admin/options.py" in 
> change_view
>   1054. self.save_model(request, new_object, form, 
> True)
> File 
> "/Library/Python/2.7/site-packages/django/contrib/admin/options.py" in 
> save_model
>   709. obj.save()
> File "/Library/Python/2.7/site-packages/django/db/models/base.py" in 
> save
>   463. self.save_base(using=using, force_insert=force_insert, 
> force_update=force_update)
> File "/Library/Python/2.7/site-packages/django/db/models/base.py" in 
> save_base
>   529. rows = 
> manager.using(using).filter(pk=pk_val)._update(values)
> File "/Library/Python/2.7/site-packages/django/db/models/query.py" in 
> _update
>   560. return query.get_compiler(self.db).execute_sql(None)
> File 
> "/Library/Python/2.7/site-packages/django/db/models/sql/compiler.py" in 
> execute_sql
>   986. cursor = super(SQLUpdateCompiler, 
> self).execute_sql(result_type)
> File 
> "/Library/Python/2.7/site-packages/django/db/models/sql/compiler.py" in 
> execute_sql
>   808. sql, params = self.as_sql()
> File 
> "/Library/Python/2.7/site-packages/django/db/models/sql/compiler.py" in 
> as_sql
>   951. val = field.get_db_prep_save(val, 
> connection=self.connection)
> File 
> "/Library/Python/2.7/site-packages/django/db/models/fields/__init__.py" in 
> get_db_prep_save
>   292.   prepared=False)
> 
> Exception Type: TypeError at 
> /admin/web/campaign/dc6eb21f-87fa-462f-88af-416cf6be37f6/
> Exception Value: get_db_prep_value() got an unexpected keyword 
> argument 'connection'
>
>
>
> **model**
>
> class Campaign(models.Model):
> campaignid = models.CharField(max_length=255, primary_key=True, 
> db_column='campaignID')
> na

Re: Reserved Words

2013-01-03 Thread Bill Freeman
That's not a reserved word.  Case in point, "list" is not a python reserved
word.  You can use it as a module level variable, but you will confuse
yourself later on when you try to use the list constructor in some code in
that module.  "else" is a reserved word.  You won't be able to redefine it,
and will get an error if you try.

"pk" is a name that is special to the ORM, but not in the rest of django.
You can use it as a variable in your views, even in model methods, and no
harm will befall you, so long as you don't prefix it with "self." in those
model methods.  There are many such circumstances in plain python, that is,
where a name is special is some particular context.  You aren't going to
find a list of those for python either.

That being said, the model documentation, I believe, and certainly
somewhere in the tutorial, I have seen documentation that "pk" is special
in a field name context.

Good luck,
Bill

On Thu, Jan 3, 2013 at 1:08 PM, Sam Raker  wrote:

> Is there a list of 'reserved words' for Django like there is for Python? I
> posted a question in here a few days ago about a mysterious recursion error
> I kept getting when I tried to load my data in with loaddata. Turns out, it
> was because I had defined a field called 'pk' with primary_key=True in my
> models. I later ran into trouble with manually-defined fields ending in
> "_id." AFAIK, neither of these little quirks are documented on the website;
> it'd be nice if they were.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/uGlhL-Fb8F8J.
> 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.
>

-- 
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: Django app custom settings testing

2013-01-03 Thread Bill Freeman
This approach is only useful for modules that import app.settings and use
things that it defines.  It doesn't affect things that import settings from
django.conf .

Your app can import settings from app, and get your settings.  That's not
going to affect any other app.  If you want to affect what other apps see,
you must either put the settings in the main settings file, or modify
django.conf.settings itself.  This last is fraught with peril, since you
can't reliably control the order in which you modify the settings object
versus when other modules may use its values in a persistent way.

Or am I missing your point?

Bill

On Thu, Jan 3, 2013 at 12:05 AM, Pedro J. Aramburu
wrote:

> Hi, I'm having troubles using the override_settings decorator. The thing
> is I'm writing an app that has it's own settings and I'm doing it with the
> approach of putting a settings.py file on the app folder with something
> like this:
>
> from django.conf import settings
> from django.core.exceptions import ImproperlyConfigured
>
>
> SETTING_A = getattr(settings, 'APP_SETTING_A', False)
>
> SETTING_B = getattr(settings, 'APP_SETTING_B', False)
>
> if SETTING_A and not SETTING_B:
> raise ImproperlyConfigured('"SETTING_A" is set to True but "SETTING_B"
> is missing.')
> -
> Where SETTING_B should be a tuple that depends on SETTING_A (I know I
> didn't type check yet). Then I use the settings importing app.settings. The
> thing is, I believe, that the settings are loaded once and as they're
> outside the project settings.py, override settings doesn't have any effect.
>
> What would you recommend?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/22xrwU84AG8J.
> 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.
>

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



Reserved Words

2013-01-03 Thread Sam Raker
Is there a list of 'reserved words' for Django like there is for Python? I 
posted a question in here a few days ago about a mysterious recursion error 
I kept getting when I tried to load my data in with loaddata. Turns out, it 
was because I had defined a field called 'pk' with primary_key=True in my 
models. I later ran into trouble with manually-defined fields ending in 
"_id." AFAIK, neither of these little quirks are documented on the website; 
it'd be nice if they were.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/uGlhL-Fb8F8J.
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: citations

2013-01-03 Thread samtygier


On Sunday, December 30, 2012 1:37:17 AM UTC, Russell Keith-Magee wrote:
>
>
> On Sat, Dec 29, 2012 at 10:26 PM, > wrote:
>
>> Hi,
>>
>> I am creating a site, and trying to implement a referencing/citation 
>> system.
>>
>> I'd like to render something like
>> "Lorem ipsum dolor sit amet[[ref:foo2012]], consectetur adipisicing elit, 
>> sed do eiusmod tempor incididunt[[ref:bar2011]] ut labore et dolore magna 
>> aliqua."
>> stored in a TextField, 
>> "Lorem ipsum dolor sit amet[1], consectetur adipisicing elit, sed do 
>> eiusmod tempor incididunt[2] ut labore et dolore magna aliqua."
>>
>> "[1] foo, 'something something' (2012)
>> [2] bar, 'something something' (2011)
>> "
>> where "foo2012" is the slug of a reference object, that has a title, 
>> author, data etc. 
>>
>> I have made a filter that can scan though a string, pick out the [[]] 
>> tags and look up the reference. I can use this in  a template like {{ 
>> site.description|refs }}. However i need somewhere to store mapping of 
>> numbers to references for that page, so that i can filter multiple blocks 
>> on the same page without resetting the numbering. I would then use a tag at 
>> the end of the page, that rendered the collected list.
>>
>> The docs on custom tags and filters talks about render_context, but does 
>> not show how to use them with filters (only with tags). 
>>
>> Am i going about this the wrong way? should filters be stateless? i 
>> realise that parsing relationships out of a text field is not good database 
>> style, but i can't think of another way to allow editors to put citations 
>> into text. i would also like to use a similar tag for cross links in the 
>> text (eg [[site:foo]] -> "/sites/view/foo").
>>
>
> What you're describing is just a markup language -- if you look in 
> django.contrib.markup, you'll find 3 examples of analogous markup 
> languages. So yes, this is an entirely appropriate way to handle 
> user-provided content.
>
> As for implementation; filters are generally stateless -- they're really 
> not much more than a way to access a function in a template. However, 
> that's got more to do with convention than hard rules. There's nothing that 
> *requires* them to be stateless. Writing to the context in a filter isn't 
> prohibited; it's just unusual (which is why the docs don't provide a 
> specific example). Using one tag to extract references, and a second to 
> print those references sounds entirely appropriate. 
>
> The other approach would be to use a template tag. The only advantage here 
> would be that tags often have context-modifying side effects, so it would 
> be marginally less surprising to an outside observer to see a tag modify 
> context. However, that's really just a developer communication issue -- if 
> there's enough documentation (formal or informal) about what the pair of 
> filters are doing, I don't see any reason why you shouldn't use a filter 
> for this purpose.
>
> Yours,
> Russ Magee %-)
>

I have it working using a filter to process the citation markup into 
numbers (eg [[ref:sam2013foo]] -> to [1]) and a tag to output the reference 
list (eg "[1] Foo Bar, sam, (2013)"). But as I can't access the render_context 
from a filter, i am storing the reference numbers in a list in global scope 
of the templatetags script. This does not seem a very good way to do it, 
and means that the tag that outputs the reference list, must clear the 
list, otherwise each time the page is refreshed the list grows.

is there anyway to find the render_context in a filter?

thanks,
Sam

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/XZjBf7DpFLwJ.
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: Using django's oodb alone

2013-01-03 Thread Nick Apostolakis

On 03/01/2013 02:30 μμ, Xavier Pegenaute wrote:

Hi,

I would like to use the django's oodb in some (ncurses + python) 
scripts. Any one have some experience on it?, do I need to use the 
django scripting environment or may be I can avoid it?



Thanks,
Xavi



Of course you can do it, you just have to import some things in order to 
load the django


I have created a number of scripts like that and have something like 
this in the begining of the file



#! /usr/bin/env python
# -*- coding: utf-8
import sys
import os
sys.path.append('./django/')
os.environ['DJANGO_SETTINGS_MODULE'] ='settings'

from myapp.models import User, Reminder, ExtraUserAttributes


etc
--

 --
   Nick Apostolakis
  e-mail: nicka...@oncrete.gr
 Web Site: http://nick.oncrete.gr
 --


--
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: Using django's oodb alone

2013-01-03 Thread Jani Tiainen

3.1.2013 14:30, Xavier Pegenaute kirjoitti:

Hi,

I would like to use the django's oodb in some (ncurses + python)
scripts. Any one have some experience on it?, do I need to use the
django scripting environment or may be I can avoid it?


Um... Django is just a Python library so you can use it like any other 
Python library, just provide configuration and you're good to go.




--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

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



Using django's oodb alone

2013-01-03 Thread Xavier Pegenaute

Hi,

I would like to use the django's oodb in some (ncurses + python) 
scripts. Any one have some experience on it?, do I need to use the 
django scripting environment or may be I can avoid it?



Thanks,
Xavi

--
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: Django installation on Hostgator

2013-01-03 Thread Avraham Serour
Hi, I'm also using hostgator to host a django project.
first of all note that they have different plans with different features,
what I'm going to write applies to their shared hosting plans.

Looks like they are using some version of centos, which comes with python
2.6 I believe.
Installing a python from source on your home folder is a good idea, but
unfortunately hostgator blocks access to gcc.
on the other hand they already have python 2.7.3 installed, juts use python2.7
as the executable, try running "python2.7 -V"
btw, they also have python2.6 for 2.6.6 and python3 for 3.2.3

after that you should use virtualenv to create a project specific env so
you can install things using pip. download the virtualenv.py file to you
project folder and run it from there. for the index.fcgi file you should
put this in the first line:
#!/home/username/projectname/env/bin/python

other than that I think it should be standard, maybe I should do a blog
posting documenting this better. let us now if this works


On Thu, Jan 3, 2013 at 6:45 AM, John Neumann  wrote:

> You can also try this: https://my.hostgator.com/cgi/help/530 and/or this:
> https://my.hostgator.sg/cgi/help/python-install though iric it was
> riddled with issues. Been a bit since I had to do it without the ability to
> install things intelligently. Personally I'd suggest trying to install
> virtualenv and see if you can even get that to work. If you can't then
> you're probably screwed (again though I'd still suggest switching hosts).
>
>
> On Wednesday, January 2, 2013 10:34:55 PM UTC-6, John Neumann wrote:
>>
>>
>> You would be correct. You cannot install anything else on HostGator (it's
>> why I left them despite their fantastic customer support). You can see what
>> they do have installed here: http://support.**hostgator.com/articles/**
>> hosting-guide/hardware-**software/python-modules
>>
>> Outside of those things you're hosed. Either find another host or lose
>> the libs. After I had the same problem I moved to WebFaction and couldn't
>> be happier there. They have great customer support as well (though I do
>> miss the ability to chat on the fly).
>>
>> Also it would be easier to install django if you had another host.
>> Hostgator is great for most things outside of Python land. Again, like
>> Hostgator, but their Python/Django support is weak sauce.
>>
>> On Wednesday, January 2, 2013 6:32:10 PM UTC-6, Gjorge Karakabakov wrote:
>>>
>>> Hi, I've created a Django project but can't really seem to install it
>>> correctly on Hostgator.
>>>
>>> I've followed this tutorial: https://docs.google.com/**document/pub?id=*
>>> *1jhvixMmTRGYHRbHaYlTHTNrtpziGo**tQMc0iBO0sTbIo
>>> and created new project which worked. When I uploaded my own project I
>>> got server error - 500.
>>> I'm presuming it has something to do with the additional apps i'm using:
>>> endless-pagination, newsletter, sorl.thumbnail, django_extensions
>>>
>>> How can install them on the server? I can't really use sudo pip install
>>> there I don't have permissions.
>>>
>>> Also is there more detailed/easier way of installing django?
>>>
>>> Please explain in detail I'm really new at django.
>>>
>>> Thanks!
>>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/Q88wygKPvGwJ.
>
> 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.
>

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