Re: Wording in Djang Docs: "per instance" vs "every instance"

2013-02-28 Thread Ivo Brodien
yeah, you are right, now I see it too…I shouldn't start reading django docs at 
the end of a working day…
cheers and thanks again!

On Feb 28, 2013, at 9:09 PM, Tomas Neme wrote:

> your view class is.. well, that, just a class.
> 
> Every time you use it in an urlpattern, calling .as_view() a new
> instance object of that class is created. So the "per instance" should
> be pretty much self explanatory
> 
> On Thu, Feb 28, 2013 at 5:04 PM, Ivo Brodien  wrote:
>> Thanks Tomas,
>> 
>> now I got it! Still the original usage of "per" and "every" sounds strange 
>> to me.. it should be more like "per instance within a URL pattern", but I am 
>> not a native in English, so nevermind.
>> 
>> Thanks!
>> 
>> On Feb 28, 2013, at 8:54 PM, Tomas Neme wrote:
>> 
>>>> This approach applies the decorator on a per-instance basis. If you want
>>>> every instance of a view to be decorated, you need to take a different
>>>> approach.
>>> 
>>> This means that with "this approach" you have to apply the decorator
>>> in every instance you want modified, that is, every time you have this
>>> 
>>> url(, YourView.as_view(),...)
>>> 
>>> and want it decorated, you need to wrap it, individually, like
>>> 
>>> url(, decorator(YourView.as_view()), )
>>> 
>>> and if you want to define the entire view as decorated, so you don't
>>> need to decorate it every time you use it in an urlpattern, because it
>>> ALWAYS needs, e.g., to be login_required, you'll need to take a
>>> different approach.
>>> 
>>> With function views, this was the normal case, because you did
>>> 
>>> @decorator
>>> def my_view(request, *args, **kwargs):
>>> ..
>>> 
>>> and you didn't need to add anything in the urls, with class-based
>>> views, you need to do this:
>>> https://docs.djangoproject.com/en/1.5/topics/class-based-views/intro/#decorating-the-class
>>> 
>>> 
>>> --
>>> "The whole of Japan is pure invention. There is no such country, there
>>> are no such people" --Oscar Wilde
>>> 
>>> |_|0|_|
>>> |_|_|0|
>>> |0|0|0|
>>> 
>>> (\__/)
>>> (='.'=)This is Bunny. Copy and paste bunny
>>> (")_(") to help him gain world domination.
>>> 
>>> --
>>> 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.
>>> 
>>> 
>> 
>> --
>> 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.
>> 
>> 
> 
> 
> 
> --
> "The whole of Japan is pure invention. There is no such country, there
> are no such people" --Oscar Wilde
> 
> |_|0|_|
> |_|_|0|
> |0|0|0|
> 
> (\__/)
> (='.'=)This is Bunny. Copy and paste bunny
> (")_(") to help him gain world domination.
> 
> -- 
> 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.
> 
> 

-- 
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: Wording in Djang Docs: "per instance" vs "every instance"

2013-02-28 Thread Ivo Brodien
Thanks Tomas,

now I got it! Still the original usage of "per" and "every" sounds strange to 
me.. it should be more like "per instance within a URL pattern", but I am not a 
native in English, so nevermind.

Thanks!

On Feb 28, 2013, at 8:54 PM, Tomas Neme wrote:

>> This approach applies the decorator on a per-instance basis. If you want
>> every instance of a view to be decorated, you need to take a different
>> approach.
> 
> This means that with "this approach" you have to apply the decorator
> in every instance you want modified, that is, every time you have this
> 
> url(, YourView.as_view(),...)
> 
> and want it decorated, you need to wrap it, individually, like
> 
> url(, decorator(YourView.as_view()), )
> 
> and if you want to define the entire view as decorated, so you don't
> need to decorate it every time you use it in an urlpattern, because it
> ALWAYS needs, e.g., to be login_required, you'll need to take a
> different approach.
> 
> With function views, this was the normal case, because you did
> 
> @decorator
> def my_view(request, *args, **kwargs):
> ..
> 
> and you didn't need to add anything in the urls, with class-based
> views, you need to do this:
> https://docs.djangoproject.com/en/1.5/topics/class-based-views/intro/#decorating-the-class
> 
> 
> --
> "The whole of Japan is pure invention. There is no such country, there
> are no such people" --Oscar Wilde
> 
> |_|0|_|
> |_|_|0|
> |0|0|0|
> 
> (\__/)
> (='.'=)This is Bunny. Copy and paste bunny
> (")_(") to help him gain world domination.
> 
> -- 
> 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.
> 
> 

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




Wording in Djang Docs: "per instance" vs "every instance"

2013-02-28 Thread Ivo Brodien
Hello,

in the Django Docs for Class Based Views[1] it says under the green box:

This approach applies the decorator on a per-instance basis. If you want every 
instance of a view to be decorated, you need to take a different approach.

I don't quite get that, since "per instance" and "every instance" is for me the 
same, although in the context above it is used as if they were different in 
order to make you use a different approach.

My English is probably not good enough to get the difference so it would be 
nice if someone could explain it to me!

Thanks! 

[1]https://docs.djangoproject.com/en/1.5/topics/class-based-views/intro/#decorating-in-urlconf

-- 
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: Highlighting Active Navigation Link - correct approach?

2012-01-10 Thread Ivo Brodien
Hi,

strange that nobody answered yet since I guess that almost everybody 
encountered the same question already.

I personally did it via a custom template tag which puts out active if the 
current URL matches the URL pattern for a view.

Cheers
Ivo

On Jan 9, 2012, at 7:27 , Victor Hooi wrote:

> hi,
> 
> I have a project where I'm using Bootstrap (www.github.com/twitter/bootstrap) 
> with Django.
> 
> I need to add a CSS class ("active") to highlight the active navigation link.
> 
> Anyhow, I did some Googling:
> 
> http://www.turnkeylinux.org/blog/django-navbar
> http://ilostmynotes.blogspot.com/2010/03/django-current-active-page-highlighting.html
> http://gnuvince.wordpress.com/2007/09/14/a-django-template-tag-for-the-current-active-page/
> http://stackoverflow.com/questions/340888/navigation-in-django
> http://djangosnippets.org/snippets/1726/
> http://stackoverflow.com/questions/7665514/django-highlight-navigation-based-on-current-page
> 
> The approach in the above seems to be to either use custom template tag, 
> middleware or JS-hackery.
> 
> Is there a current consensus in the Django community in terms of what is the 
> "correct" approach for this?
> 
> Is there a reason something like this isn't part of Django core, or an 
> in-built templatetag?
> 
> Cheers,
> Victor
> 
> -- 
> 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/-/Xx5Rk_rBuxIJ.
> 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.



App for manage renting/booking management

2012-01-08 Thread Ivo Brodien
Hi,

does anyone know of a Django app that handles the bookings and renting of a 
house that can be rented.

I imagine something like this:
- forms for booking
- in the admin: 
- status management of the booking inquiries
- sending out payment confirmations
- maintaining a calendar to show available/reserved dates in an online 
calendar

Thanks!
Ivo

-- 
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: Is models.DateTime timezone aware ?

2012-01-08 Thread Ivo Brodien
Hi,

I did not read the details of your question, but I can tell you that Django 
will be timezone aware in 1.4.

https://docs.djangoproject.com/en/dev/releases/1.4-alpha-1/#support-for-time-zones

cheers
Ivo

On Jan 8, 2012, at 0:40 , Matěj Cepl wrote:

> I have in my first Django app this model (selection):
> 
> class Post(models.Model):
># ...
>updated = models.DateTimeField(default=datetime.datetime.now())
>published = models.DateTimeField(blank=True)
> 
> When looking at the database dump of the generated database I see that the 
> date is saved as timezone aware:
> 
> '2008-07-10 10:00:00+02:00','2008-07-10 10:00:00+02:00'
> 
> However, when in the test I try
> 
>self.assertEqual(test_entry.updated,
>dateutil.parser.parse(u"2008-07-10T10:00:00+02:00"))
> 
> test fails, and I can use only
> 
>self.assertEqual(test_entry.updated,
>dateutil.parser.parse(u"2008-07-10T10:00:00"))
> 
> What am I missing? Any thoughts, please?
> 
> Thank you,
> 
> Matěj
> 
> -- 
> http://www.ceplovi.cz/matej/, Jabber: mceplceplovi.cz
> GPG Finger: 89EF 4BC6 288A BF43 1BAB  25C3 E09F EF25 D964 84AC
> 
> Of all tyrannies, a tyranny exercised for the good of its
> victims may be the most oppressive. It may be better to live
> under robber barons than under omnipotent moral busybodies. The
> robber baron's cruelty may sometimes sleep, his cupidity may at
> some point be satiated; but those who torment us for our own
> good will torment us without end, for they do so with the
> approval of their consciences.
>-- C. S. Lewis
> 
> -- 
> 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.



Re: Skip upload of existing S3 Object

2012-01-01 Thread Ivo Brodien
Hi,

the form sends the picture to S3 and then S3 calls you on an URL which you 
specify with “ success_action_redirect”. This should point to an URL on your 
server where you then store the key/hash which will be provided in the URL.

Your code uses POST data but S3 will put the metadata in the URL (=GET) 
(bucket, key and etag)

So just make sure that your forms posts to S3 and you define the 
success_action_redirect URL.

I think you actually don’t need the S3StorageBackend since you are not storing 
anything or at least it does not actually pass your server.

hope that helps!

Cheers
Ivo


On Jan 1, 2012, at 12:25 , Chris Hasenpflug wrote:

> I have a model with an ImageField and am using django-storages
> S3BotoStorage backend. To reduce load on the server, I'm using
> Amazon's S3 Browser Upload functionality[1] to send images directly to
> S3. In order to create the model, my plan is have another view take
> the uploaded key and save a model instance of my image.  Currently my
> view code looks something like this:
> 
> def add_existing_image(request):
>...
>image_key = request.POST.get('image_key', None)
>im = default_storage.open(image_key)
>i = Image(image=im, owner=user)
> 
> However, this seems to re-save the image on S3. I was hoping that
> since I'm not directly reading the file it would not need to do so
> behind the scenes, but it is. Since the goal is to not incur that
> overhead, how should I go about creating model instances of these
> files that already exist in my storage?
> 
> [1] http://aws.amazon.com/articles/1434
> 
> -- 
> 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.



Re: Why when upload PDFs, Django says the content type is "application/text"?

2011-12-25 Thread Ivo Brodien
> I was getting "application/pdf" a few days ago with same client,
> server, browser, etc.

If this really is the case and the code is exactly the same, maybe it depends 
somehow on the PDF itself? Did you check that?

-- 
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: Confused by STATICFILES_DIRS not working

2011-12-16 Thread Ivo Brodien
Hi,

I am not trying to understand what you did but just tell you how t works for me:

PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
STATIC_ROOT = os.path.join(PROJECT_PATH, 'static')
STATIC_URL = '/static/‘

INSTALLED_APPS = (
...

'django.contrib.staticfiles’,
)

I have no STATICFILES_DIRS defined since for me it is enough how  
STATICFILES_FINDERS finds static content.

I think what you get wrong, is that you want to add your folder where you want 
your static content to be collected to  STATICFILES_DIRS, but that must be 
defined in STATIC_ROOT and should not be left empty.

When you do runserver it will find and serve all static content automatically

for example static content that is in one of your apps:

django_sites/new_rcfhostdb/MYAPP/static (you DONT have to put this in 
STATICFILES_DIRS)

When you then run the collectstatic (usually on the production server) command 
all static content will be copied to STATIC_ROOT and I guess you want this to 
be: 

django_sites/new_rcfhostdb/static

You have to copy all the static content to one location because only then the 
Webserver can find and serve all the static content which should not be the job 
of the django process.


Please read for further information:

https://docs.djangoproject.com/en/1.3/howto/static-files/

Good luck
Ivo





On Dec 16, 2011, at 17:08 , Jeff Blaine wrote:

> I'm having a heck of a time getting STATICFILES_DIRS working.  If anyone 
> could shed some light on this or just point me to the "All of your Django 
> STATIC* Settings Clarified Completely Once and For All" blog post or 
> somesuch, I would really appreciate it.
> 
> STATIC_ROOT = '' # DEFAULT
> STATIC_URL = '/static/' # DEFAULT
> STATICFILES_DIRS = ( 
> '/django_sites/new_rcfhostdb/static',
> ) 
> 
> Proof the intended CSS file exists in STATICFILES_DIRS:
> 
> -rw-r--r-- 1 jblaine wheel 56360 Dec 14 19:06 
> /django_sites/new_rcfhostdb/static/bootstrap.css 
> 
> I issue a GET /hostdb/ 
> 
> "ImproperlyConfigured: The STATICFILES_DIRS setting should not contain the 
> STATIC_ROOT setting" 
> 
> Fine.
> 
> STATIC_ROOT = '/tmp/SHUT_UP' 
> 
> That stops the 'ImproperlyConfigured' exception.
> 
> The various attempted stylesheet references (from my base.html template) and 
> their 404 errors: 
> 
>  
> 
> [16/Dec/2011 10:53:04] "GET /bootstrap.css HTTP/1.1" 404 2146 
> 
>  
> 
> [16/Dec/2011 10:53:08] "GET /hostdb/bootstrap.css HTTP/1.1" 404 2146 
> 
>  
> 
> [16/Dec/2011 10:57:13] "GET /static/bootstrap.css HTTP/1.1" 404 1741
> 
> -- 
> 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/-/cSCoskQNgFYJ.
> 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: Creating websites like Amazon/Ebay using Django

2011-12-16 Thread Ivo Brodien
and keep in mind, that you don’t have to reinvent the wheel. There are open 
source solutions for shops:

Like: http://www.getlfs.com/released-06-beta-1

cheers

On Dec 16, 2011, at 11:17 , Joey Espinosa wrote:

> Cata,
> 
> Yes, Django is exactly suited for this scenario. The structure of Django 
> allows you to create scalable, flexible sites with the freedom to expand the 
> database as needed without having to worry about messing with the code so 
> much in order to do so.
> 
> That being said, I'd HIGHLY recommend you get familiar with JS and HTML. 
> While Django can provide you the backend foundation for your sites, you need 
> HTML (and likely JS as well) on the front end to present your backend data. 
> In fact, I'd say that's (HTML) extremely important, because it's the part 
> that's going to interact directly with your customer base. It can easily make 
> or break your site, regardless of how good your backend code is.
> 
> Hope this helped.
> --
> Joey "JoeLinux" Espinosa
> 
> 
> 
> 
> On Fri, Dec 16, 2011 at 2:06 AM, Cata  wrote:
> Hello everyone,
> 
> I am basically working on creating a website on the lines of Amazon/
> Ebay  wherein user can browse/buy/sell items. I intend to make a basic
> website first then build on top of it.
> 
> Till now i have been mostly programming in C/C++ & used Python as an
> automation tool . I am not familiar with any of the Web programming
> languages such as MySQL , JavaScript, HTML , honestly i do not even
> know what these are.
> 
> My question is will Django be suitable for the above tasks ? I have
> just installed the framework & going through the tutorials & so far
> it's been wonderful experience
> 
> Please pitch in
> 
> Thanks
> Cata
> 
> --
> 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.

-- 
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: 2 questions about Django

2011-12-14 Thread Ivo Brodien


> 1) Can I make a site like this one (http://www.tamarawobben.nl) with
> Django.
> Till now I find no solution which I can have different numbers of
> articles on pages.

Yes, of course you can. You can almost do anything with Django as django to put 
it simply mainly will output HTML Code which is what you want for a webpage.

It looks like you are looking for a blogging app for django.

Just search for it with your favorite search engine.

cheers
Ivo

-- 
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: Website Statistics - What should I use to have Google Analytics in Django?

2011-12-01 Thread Ivo Brodien
>> Out of curiousity:
> 
> Is there anything similiar  which does work well in an intranet
> environment or an environment, where one does not want to send data to a
> third party server?

Not Django but  Piwik (MySQL, PHP) can do this.

http://piwik.org/

-- 
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: A view associated with a lot of urls

2011-11-30 Thread Ivo Brodien

> Well I agree that if the category doesn't exist he will get a 404. But
> if the Category exists and there are no items in the 'table', it will
> not be empty, it will also raise a 404 too.  That's why I wrote :
> 
>> However with that, there is no way for example to make a difference
>> between "there is no items in this category" and "this category
>> doesn't exist” !

No. with the line below items will be empty ant not 404.

items= get_object_or_404(Category,name=category).items().filter(name=item)

or  items without the brackets. (not sure about the syntax at the moment)

The above is the same as:

# This could produce 404
category = get_object_or_404(Category,name=category)

# This will result in an empty queryset and not 404 
items = category.items().filter(name=item)

It is also obvious that the last line does not produce 404 since 404 is HTML 
related and the line above is a DB query which at most should result in 
something empty.

I just saw your answer about using NoSQL. Sorry, forgot about that.

In that case I cannot help you.

Good Luck

-- 
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: A view associated with a lot of urls

2011-11-30 Thread Ivo Brodien

> I don't quite understand what you mean here. You want me to create a
> CategoryModel of which all my Category models should be derived ? If
> that's it, how can it help me to determine if URL is valid or not, I
> can't see how that works.

Sorry, it was DrBloodmoney, who wrote this:

> class Category(models.Model):
>name = models.CharField # should be unique
> 
> class Item(models.Model):
>  name = models.CharField()
>   category = models.ForeignKey(Category, related_name='items’)


in your view you do so:

def view(request, category, item):
 items= get_object_or_404(Category,name=category).items().filter(name=item)
 

That’s it.

Now if someone enters a category by hand which does not exist, he gets a 404. 
If the category exists, but there is no item with such a name items will be 
empty.

Bye
Ivo

-- 
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: A view associated with a lot of urls

2011-11-30 Thread Ivo Brodien
Hi,

> That's why I'm
> considering checking at the beginning of the view with a list/dict
> filled with category names and one filled with item names to make sure
> that the category is in the list/dict and same for the item before
> hitting the database, and if not respond with a 404.

As Reinout suggested you should have a CategoryModel which you can check if a 
Category exists and the get the items of show that the category does not exist 
or 404 if somebody entered a wrong URL/Category. Checking against the DB is 
probably the same thing you want to do, but it uses the DB and not a List/Dict 
which you have to maintain manually somehow.

I think you care too much about people entering wrong URLs. People are clicking 
links on your webpage, right? Or do you give him instructions to write urls in 
the adress field?

As long as you produce correct urls the code works and only should show 404 if 
someone messed with the URL.

Consider doing this:

1) use the url tag or get_absolute_url of your models to produce the urls in 
your template
2) configure your site to send you 404 errors which have a referer (read below 
and [1])

404 errors
Django can also be configured to e-mail errors about broken links (404 “page 
not found” errors). Django sends e-mails about 404 errors when:
DEBUG is False
SEND_BROKEN_LINK_EMAILS is True
Your MIDDLEWARE_CLASSES setting includes CommonMiddleware (which it does by 
default).
If those conditions are met, Django will e-mail the users listed in the 
MANAGERS setting whenever your code raises a 404 and the request has a referer. 
(It doesn’t bother to e-mail for 404s that don’t have a referer – those are 
usually just people typing in broken URLs or broken Web ‘bots).


bye

[1] https://docs.djangoproject.com/en/1.3/howto/error-reporting/

-- 
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: Authentication backend

2011-11-25 Thread Ivo Brodien
Hi,

You provided no code, no question, no error, would be a miracle if somebody 
would be able to help you.

Cheers
Ivo

On Nov 25, 2011, at 6:29, shaini sasidhar  wrote:

> Hi...
> 
>   I had configured Django admin site with MySQL database and it
> works fine..But I want to customize the authentication backend.Created
> my own authentication backend and added in settings.py file.But the
> login doesnot work properly.I think the user object creation in model
> class troubles me..
> 
> -- 
> 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.



Re: iterating through lists in templates

2011-11-25 Thread Ivo Brodien

{% for image in images %}
{{ image }}

If you need numbers there are counters for for-loops

On Nov 25, 2011, at 14:18, marjenni  wrote:

> {% for i in numberOfImages %}

-- 
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: iterating through lists in templates

2011-11-25 Thread Ivo Brodien
You should pass a list of images to the template and iterate over this list.

On Nov 25, 2011, at 14:18, marjenni  wrote:

> Hi all,
>  Why does this not work?
> 
>{% for i in numberOfImages %}
>  
>  {{ images.i}} 
> 
> numberOfImages is the number of items in the images list.
> 
> I have a workaround using images.pop, but ideally i would like to be
> able to use an array index.
> 
> all help much appreciated
> 
> Mark
> 
> -- 
> 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.



Re: Reverse and variables in template

2011-11-24 Thread Ivo Brodien
Don't use brackets around the variables.


On Nov 25, 2011, at 1:48, youpsla  wrote:

> Hello,
> 
> The following line in my template return an error:
> Modifier
> 
> Error is:
> Could not parse the remainder: '{{' from '{{'
> 
> If i use (has view in the doc):
> Modifier
> it works fine.
> 
> Then is the syntax {% url url_name {{model.field}} %} allowed ?
> 
> Somebody has an idea ?
> 
> Thanks for your precious help.
> 
> Regards
> 
> youpsla
> -- 
> 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/-/1IxshdRdwksJ.
> 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: Installation of Django

2011-11-24 Thread Ivo Brodien

> windows users have extracted your command will look like this: ...
> to execute the .tar file.

as tom mentioned, you have to use 7zip two times.

the tar file is another archive (like .zip, .gz ) which you have to decompress 
and then you have the django directory and you can go on with the tutorial.


On Nov 24, 2011, at 17:55 , JJ Zolper wrote:

> JoeLinux,
> 
> Oh interesting. It seems the 64 bit version is sort of unclear. Any
> help there?
> 
> Would I be able to install my Python is well with a smaller command? I
> am back at ground zero because I had to adjust the Python version back
> to 2.5 so Django would agree.
> 
> I am interested just not sure how to work the 64 bit version.
> 
> Thanks!
> 
> JJ
> 
> On Nov 24, 11:40 am, Joey Espinosa  wrote:
>> If you install the "setuptools" package (http://goo.gl/UjFh), then all you
>> have to do to install Django (or any other Python library) is this:
>> 
>> easy_install django
>> 
>> And it will handle the rest. Just a suggestion.
>> 
>> --
>> Joey "JoeLinux" Espinosa
>> Software Developerhttp://about.me/joelinux
>> On Nov 24, 2011 10:37 AM, "Tom Evans"  wrote:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> On Thu, Nov 24, 2011 at 5:00 AM, JJ Zolper  wrote:
 Hello,
>> 
 I am new to Django! I was able to download and install: Python 2.7.2
 x86 64 on my Windows 7 64 bit machine. I think that is all that I will
 need to execute the command line?
>> 
 I installed Python to C:/Python27 as the program intended.
>> 
 I then downloaded: Django-1.3.1.tar.gz file and was try to figure
 where to go to next. I used the 7 zip to extract it to:
 Django-1.3.1.tar. But I wasn't sure the next steps. I opened the
 Python cmd prompt. I typed the command in: tar xzvf Django-*.tar.gz.
 But I got errors about the portion "xzvf" I feel that the directories
 are not set up correctly. Do I need to adjust my command for the
 directory because I already tried that.
>> 
 I would really appreciate a step through that would get me all set up
 with the baseline. I am interested to moving on from to the more in
 depth chapters. I tried hard to understand the input from the comments
 on the page but I was unable to find anything that gave me any sense
 of direction on how to place the Django files.
>> 
 Thanks!
>> 
 JJ
>> 
 PS. sorry this is available and I didn't see it in the new booklet.
>> 
>>> tar.gz is a gzipped (.gz) tape archive (.tar) file. 7zip should be
>>> able to gunzip it and extract the files from the archive - it might
>>> require two steps.
>> 
>>> The 'tar xzvf…' command is how one extracts a tar.gz under unix/linux
>>> from the OS command line - not the python command line. As the docs
>>> say, you can download and install bsdtar in windows, in which case the
>>> OS command would be 'bsdtar zxvf …'.
>> 
>>> This is the second time this week someone has had issues extracting a
>>> tgz on windows - any chance that django could be packaged up in a more
>>> Windows friendly zip file format in addition to tgz?
>> 
>>> Cheers
>> 
>>> Tom
>> 
>>> https://docs.djangoproject.com/en/1.3/topics/install/#installing-an-o...
>> 
>>> --
>>> 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.
> 

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



google always finds development version first

2011-11-24 Thread Ivo Brodien
Hi,

although I know i should bookmark things, but often I find myself googling for 
some django docs and google always shows the development version. 

Wouldn’t it be more useful, if the docs of the latest release would be shown 
first?

I understand it might be googles algorithms of showing the newest pages but I 
am sure something can be done about it.

Cheers
ivo

-- 
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: Seeking example of django.contrib.staticfiles usage

2011-11-24 Thread Ivo Brodien
>  3) Have django.contrib.staticfiles to serve static content (perhaps
> non-optimally) from the Django runtime.

this is just for developing purposes. 1) 2) are the ways to go.

> Is there a simple example of #3 (the only one that lets me package up
> a complete "app")?
> 
> I've read:
> https://docs.djangoproject.com/en/dev/howto/static-files/

that is the development version

https://docs.djangoproject.com/en/1.2/howto/static-files/

>  And
> when I add "django.contrib.staticfiles" the runtime simply reports
> "Error: No module named staticfiles”.

that is because django.contrib.staticfiles is there since 1.3

> Is there a good working tested example out there?
> 
> # django-admin.py --version
> 1.2.5

switch to 1.3.1 and then you can use django.contrib.staticfiles.

Ivo

-- 
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 : CSRF and variable handling in a view

2011-11-24 Thread Ivo Brodien
Hi!

Ah, ok. Now it makes a more sense - index was indeed confusing.

Well in your template I would just make the check and show the form or not.

If your don’t show the form, the user cannot make a POST to the signup view 
since he does not have a valid CSRF token.

Anyway, if the user is logged in there should not be a Link to the signup page 
and even if he enters the signup form url by hand, he will see no form.

Ah, and don’t worry about the RequestContext. I don’t think that it causes any 
important amount of overhead. The processing was done anyways before, so its 
just a matter of making it available to the template or not. And you will see, 
that you will use it often in your templates.

Ivo
On Nov 24, 2011, at 14:25 , Nolhian wrote

> Hello,
> 
> First of all thanks for your answer !
> I think that the name I gave "index.html" is causing confusion. In
> fact that's the first view I created and so the only template I have
> at the moment and I awkwardly named it index.html, It should be named
> signup.html or something like that. I'm not looking to handle log in
> and logout here, just making sure that a logged user cannot sign-up
> again ( which would be a nonsense and in my opinion a flaw ),this is
> my signup form view which is located at /subscribe/.
> 
> Is it better with these explications or does the approach I'm taking
> still feel weird ?
> 
> Nolhian
> 
> On Nov 24, 1:37 pm, Ivo Brodien  wrote:
>> DrBloodMoney is right, It is kind of odd how you are solving the problem but 
>> it might me kind of right depending on what you are trying to do.
>> 
>> Considering how most of the websites work you should do this.
>> 
>> In all the templates include another template which does this:
>> 
>> {% if not user.is_authenticated %}
>> LINK Login | Link Sign Up
>> {% else %}
>> Logged in as username | Link Logout
>> {% endif %}
>> 
>> Logout, Login and Sign Up are handled by different urls/views and not the 
>> index or any other view
>> 
>> if you want to make a view available only to authenticated users, use the 
>> @login_required decorator.[2]
>> 
>> If you are using the provided django.auth system the views for login, logout 
>> are already there. In the settings you can define some behavior.
>> 
>> See the settings LOGIN_REDIRECT_URL, LOGIN_URL, LOGOUT_URL [1]
>> 
>> [1]https://docs.djangoproject.com/en/1.3/ref/settings/#login-url
>> [2]https://docs.djangoproject.com/en/1.3/topics/auth/#the-login-required...
>> 
>> On Nov 24, 2011, at 3:31 , Nolhian wrote:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>>> This seems all sorts of wrong to me. Why couldn't the user just log
>>>> out and then post? Seems like an odd workflow, but I don't know your
>>>> business-case here.
>> 
>>> Yes the user can just log out and then post but since this is a sign-
>>> up form it would seem logical to not be able to sign-up if the user is
>>> logged in which means he already has an account.
>> 
>>>> You could always control what is shown to the user in the template (to
>>>> limit their ability to use your form to post to the view) with
>> 
>>>> {% if not user.is_authenticated %}
>>>> SHOW FORM
>>>> {% else %}
>>>> you're logged in so you can't post
>>>> {% endif %}
>> 
>>> That's kind of what I'm doing but I still need to check somewhere in
>>> the view if the user is logged in. If I don't the user can open the
>>> sign-up form page, then open another page of the site and log in, then
>>> switch back to the sign-up form page, send the form ( which will be
>>> validated in the view since there's no checking if the user is
>>> authenticated or not there ) and successfully sign-up again WHILE
>>> being logged in. To be able to do that just seems wrong to me.
>> 
>>> --
>>> 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 
>>> athttp://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.



Re: Django : CSRF and variable handling in a view

2011-11-24 Thread Ivo Brodien
DrBloodMoney is right, It is kind of odd how you are solving the problem but it 
might me kind of right depending on what you are trying to do.

Considering how most of the websites work you should do this.

In all the templates include another template which does this:

{% if not user.is_authenticated %}
LINK Login | Link Sign Up
{% else %}
Logged in as username | Link Logout
{% endif %}

Logout, Login and Sign Up are handled by different urls/views and not the index 
or any other view

if you want to make a view available only to authenticated users, use the 
@login_required decorator.[2]

If you are using the provided django.auth system the views for login, logout 
are already there. In the settings you can define some behavior.

See the settings LOGIN_REDIRECT_URL, LOGIN_URL, LOGOUT_URL [1]

[1] https://docs.djangoproject.com/en/1.3/ref/settings/#login-url
[2] 
https://docs.djangoproject.com/en/1.3/topics/auth/#the-login-required-decorator






On Nov 24, 2011, at 3:31 , Nolhian wrote:

>> This seems all sorts of wrong to me. Why couldn't the user just log
>> out and then post? Seems like an odd workflow, but I don't know your
>> business-case here.
> 
> Yes the user can just log out and then post but since this is a sign-
> up form it would seem logical to not be able to sign-up if the user is
> logged in which means he already has an account.
> 
>> You could always control what is shown to the user in the template (to
>> limit their ability to use your form to post to the view) with
>> 
>> {% if not user.is_authenticated %}
>> SHOW FORM
>> {% else %}
>> you're logged in so you can't post
>> {% endif %}
> 
> That's kind of what I'm doing but I still need to check somewhere in
> the view if the user is logged in. If I don't the user can open the
> sign-up form page, then open another page of the site and log in, then
> switch back to the sign-up form page, send the form ( which will be
> validated in the view since there's no checking if the user is
> authenticated or not there ) and successfully sign-up again WHILE
> being logged in. To be able to do that just seems wrong to me.
> 
> -- 
> 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.



Re: Named URLs Error

2011-11-24 Thread Ivo Brodien
forget my previous post, it is wrong.

> /templates/products/index.html
> --
>  Products 
> 
> Error
> --
> In template /home/user/app/templates/inc/header.html, error at line 18
>   Caught ImportError while rendering: No module named urls

see that there are different templates.

can you show what is happening in:

template /home/user/app/templates/inc/header.html, error at line 18


-- 
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: Named URLs Error

2011-11-24 Thread Ivo Brodien
Not sure but I think you have to put  {% load tags %} in your template.


On Nov 24, 2011, at 6:07 , eeyore wrote:

> This seems like a very simple problem but I can't figure out why it
> doesn't work.
> 
> What I am trying to do is to link to a particular view via a named
> url.
> 
> 
> /urls.py
> --
> urlpatterns = patterns('',
>(r'^products/', include('products.urls')),
> )
> 
> /products/urls.py
> --
> from django.conf.urls.defaults import patterns, url
> 
> urlpatterns = patterns('products.views',
>url(r'^$', view="index", name="products_index"),
> )
> 
> /templates/products/index.html
> --
>  Products 
> 
> Error
> --
> In template /home/user/app/templates/inc/header.html, error at line 18
>   Caught ImportError while rendering: No module named urls
> 
> -- 
> 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.



Re: Very strange KeyError on 'PORT' in db/backends/mysql/base.py

2011-11-23 Thread Ivo Brodien
just another wild guess:

in django/db/utils.py Line 84:

for setting in ('NAME', 'USER', 'PASSWORD', 'HOST', 'PORT'):
conn.setdefault(setting, ‘’)

It looks like PORT is set to ‘’ instead of 3306 if missing. But still it should 
be in the dict.

really strange, yes.

-- 
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: Very strange KeyError on 'PORT' in db/backends/mysql/base.py

2011-11-23 Thread Ivo Brodien


> * Colleagues have been unable to reproduce this using very similar stacks 
> which could mean it's OS related to threading or something really low-level. 
> Sigh...

maybe I did a wrong search, but I did

grep -r '3306’ . 

inside the django directory and could not find a place where the default port 
is specified.

Shouldn’t it be there or is this specified in e.g. MySQLdb?


-- 
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: displaying images

2011-11-23 Thread Ivo Brodien
Hi,

did you read and do the tutorials? If not do it and you will learn a lot. [1]

In the tutorial you would learn that you would not want to write HTML code 
inside a view (function) but in a HTML template.

You should also read about how to server static media.[2]

[1] https://docs.djangoproject.com/en/1.3/intro/tutorial01/
[2] https://docs.djangoproject.com/en/1.3/howto/static-files/

Good luck

On Nov 23, 2011, at 17:31 , marjenni wrote:

> Hi all,
>   Again, I am sure this is a very common problem for beginners, but
> all help appreciated.
> 
> 
> In a python function I am building a webpage,  and trying to add
> images to a table like this:
> 
> html += " 
> " % imageName
> 
> return HttpResponse(html)
> 
> 
> Now the table is displayed fine, but images are missing.
> 
> The images are present in the directory /home/www/mysite/images/
> 
> and in settings.py
> 
> MEDIA_URL = '/home/www/mysite/cache/'
> 
> any suggestions?
> 
> many thanks
> 
> Mark
> 
> 
> 
> 
> 
> -- 
> 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.



Re: 'function' object has no attribute 'as_view'

2011-11-23 Thread Ivo Brodien

> I've done the test with another class, it's the same. Then I think 
> @login_required works only for function and not for Class.

https://docs.djangoproject.com/en/dev/topics/class-based-views/#decorating-class-based-views

explains how to use decorators for classes.

-- 
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: How-to for static files?

2011-11-23 Thread Ivo Brodien
Great. Glad te be of help.

and yes, the missing RequestContext was what was missing. And insteas of trying 
months for yourself just drop a few lines here on that list in the furure ;-)

happy coding!

On Nov 23, 2011, at 15:13 , Guillaume Chorn wrote:

> IT WORKED!!!  Holy cow.  So my main issue was just not using RequestContext, 
> right?  Either way, thank you SO much.  I have been stuck at this point for 
> months!  I can now TRULY begin working on my website.  Wow.  Thank you. So. 
> Much.
> 
> best,
> Guillaume
> 
> On Wed, Nov 23, 2011 at 9:53 PM, Ivo Brodien  wrote:
> ok, i think we got it.
> 
> def items(request):
> item_list=Item.objects.all()
> return render(request, 'myapp/items.html', {'items_list':items_list},
> content_type="text/css")
> 
> you are returning html and text/css. Your HTML includes a CSS but that is a 
> different story. The Browser will ask for the included CSS file in a 
> different request to the server and the server responds with a static file 
> from disk without going through any of your views.
> 
> so just remove content_type
> 
> or put it to text/html which is the default.
> 
> Your browser thinks it is a CSS file instead of HTML.
> 
> cheers
> Ivo
> 
> 
> On Nov 23, 2011, at 14:40 , Guillaume Chorn wrote:
> 
>> Oops, I guess maybe you meant since I've changed the views.py file since I 
>> last included it?  Here is the newest version:
>> 
>> http://dpaste.com/660808/
>> 
>> thanks,
>> Guillaume
>> 
>> On Wed, Nov 23, 2011 at 9:36 PM, Guillaume Chorn  
>> wrote:
>> Sorry, I thought I included my views.py earlier, but here it is:
>> 
>> http://dpaste.com/660653/
>> 
>> It is the 
>> 
>> (r'^items/$','myapp.views.items')
>> 
>> which is not working.  It shows the expected HTML source--basically, exactly 
>> what I have in the template file, except {{ STATIC_URL }} has been changed 
>> to '/static' and all of the template tags have been replaced by actual 
>> values.  So yes, I think that it's just not rendered.  What could cause this?
>> 
>> thanks,
>> Guillaume
>> 
>> 
>> On Wed, Nov 23, 2011 at 8:23 PM, Ivo Brodien  wrote:
>> show your myapp.views.py file and is it the 
>> (r'^home/$','myapp.views.homepage'),
>> 
>> which is not working?
>> 
>> Is it showing the html source that you expect just not rendered or something 
>> else?
>> 
>> It is always a good idea to provide as much details as possible.
>> 
>> But yeah, we are getting close.
>> 
>> cheers
>> Ivo
>> 
>> 
>> 
>>> Gah!  Removed it, but now when I load up the page, it just shows me HTML 
>>> source code.  The rest of the views work fine.  
>>> 
>>> Sorry for all this trouble.  But at least something is happening with each 
>>> change you suggest!  I now have more hope than I've had in quite a while.  
>>> I think we're getting close! =)
>>> 
>>> thanks,
>>> Guillaume
>>> 
>>> On Wed, Nov 23, 2011 at 8:08 PM, Ivo Brodien  wrote:
>>> you did not read the post by Tom Evans, did you? ;)
>>> 
>>> remove "django.core.context_processors.tz”,
>>> 
>>> or just put:
>>> 
>>> ("django.contrib.auth.context_processors.auth",
>>> "django.core.context_processors.debug",
>>> "django.core.context_processors.i18n",
>>> "django.core.context_processors.media",
>>> "django.core.context_processors.static",
>>> "django.contrib.messages.context_processors.messages")
>>> 
>>> 
>>> It was a mistake by me. I posted the one from the dev version.
>>> 
>>> does it work now?
>>> 
>>> 
>>> 
>>> On Nov 23, 2011, at 13:02 , Guillaume Chorn wrote:
>>> 
>>>> Hi,
>>>> 
>>>> Thanks for continuing to follow up on this.  Something is definitely 
>>>> happening now.  I went ahead and put this into my views.py:
>>>> 
>>>> from django.shortcuts import render
>>>> 
>>>> def items(request):
>>>> item_list=Item.objects.all()
>>>> return render(request, 'myapp/items.html', {'item_list':item_list},
>>>> content_type="text/css")
>>>> 
>>>> And now when I try to load the page, I get the following error:
>>&g

Re: How-to for static files?

2011-11-23 Thread Ivo Brodien
ok, i think we got it.

def items(request):
item_list=Item.objects.all()
return render(request, 'myapp/items.html', {'items_list':items_list},
content_type="text/css")

you are returning html and text/css. Your HTML includes a CSS but that is a 
different story. The Browser will ask for the included CSS file in a different 
request to the server and the server responds with a static file from disk 
without going through any of your views.

so just remove content_type

or put it to text/html which is the default.

Your browser thinks it is a CSS file instead of HTML.

cheers
Ivo


On Nov 23, 2011, at 14:40 , Guillaume Chorn wrote:

> Oops, I guess maybe you meant since I've changed the views.py file since I 
> last included it?  Here is the newest version:
> 
> http://dpaste.com/660808/
> 
> thanks,
> Guillaume
> 
> On Wed, Nov 23, 2011 at 9:36 PM, Guillaume Chorn  
> wrote:
> Sorry, I thought I included my views.py earlier, but here it is:
> 
> http://dpaste.com/660653/
> 
> It is the 
> 
> (r'^items/$','myapp.views.items')
> 
> which is not working.  It shows the expected HTML source--basically, exactly 
> what I have in the template file, except {{ STATIC_URL }} has been changed to 
> '/static' and all of the template tags have been replaced by actual values.  
> So yes, I think that it's just not rendered.  What could cause this?
> 
> thanks,
> Guillaume
> 
> 
> On Wed, Nov 23, 2011 at 8:23 PM, Ivo Brodien  wrote:
> show your myapp.views.py file and is it the 
> (r'^home/$','myapp.views.homepage'),
> 
> which is not working?
> 
> Is it showing the html source that you expect just not rendered or something 
> else?
> 
> It is always a good idea to provide as much details as possible.
> 
> But yeah, we are getting close.
> 
> cheers
> Ivo
> 
> 
> 
>> Gah!  Removed it, but now when I load up the page, it just shows me HTML 
>> source code.  The rest of the views work fine.  
>> 
>> Sorry for all this trouble.  But at least something is happening with each 
>> change you suggest!  I now have more hope than I've had in quite a while.  I 
>> think we're getting close! =)
>> 
>> thanks,
>> Guillaume
>> 
>> On Wed, Nov 23, 2011 at 8:08 PM, Ivo Brodien  wrote:
>> you did not read the post by Tom Evans, did you? ;)
>> 
>> remove "django.core.context_processors.tz”,
>> 
>> or just put:
>> 
>> ("django.contrib.auth.context_processors.auth",
>> "django.core.context_processors.debug",
>> "django.core.context_processors.i18n",
>> "django.core.context_processors.media",
>> "django.core.context_processors.static",
>> "django.contrib.messages.context_processors.messages")
>> 
>> 
>> It was a mistake by me. I posted the one from the dev version.
>> 
>> does it work now?
>> 
>> 
>> 
>> On Nov 23, 2011, at 13:02 , Guillaume Chorn wrote:
>> 
>>> Hi,
>>> 
>>> Thanks for continuing to follow up on this.  Something is definitely 
>>> happening now.  I went ahead and put this into my views.py:
>>> 
>>> from django.shortcuts import render
>>> 
>>> def items(request):
>>> item_list=Item.objects.all()
>>> return render(request, 'myapp/items.html', {'item_list':item_list},
>>> content_type="text/css")
>>> 
>>> And now when I try to load the page, I get the following error:
>>> 
>>> ImproperlyConfigured at /diseases/
>>> 
>>> Module "django.core.context_processors" does not define a "tz" callable 
>>> request processor
>>> 
>>> Request Method: GET
>>> Request URL: http://127.0.0.1:8000/diseases/
>>> Django Version: 1.3.1
>>> Exception Type: ImproperlyConfigured
>>> Exception Value: 
>>> 
>>> Module "django.core.context_processors" does not define a "tz" callable 
>>> request processor
>>> 
>>> Exception Location: 
>>> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/context.py
>>>  in get_standard_processors, line 154
>>> Python Executable: 
>>> /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
>>> Python Version: 2.7.2
>>> Python Path: 
>>> 
>>> ['/Users/guillaumechorn/Documents/pharmapi

Re: Django : CSRF and variable handling in a view

2011-11-23 Thread Ivo Brodien
no problem.

> I also pass has_account=True in the view if the user is authenticated.

in this case in your template you can just do:

{% if user.is_authenticated and user.is_active %}

That is the advantage of using RequestContext.

-- 
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: 'function' object has no attribute 'as_view'

2011-11-23 Thread Ivo Brodien
yeah, very strange.

> url(r"magasin/(?P\d+)/evenement/new/$",
> EvenementCreateView.as_view(model=Evenement),
> name='new_evenement_magasin'),

and you are sure the error is caused by the line above? Commenting it out and 
works? Just asking, since you did not provide the whole error description?

-- 
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: How-to for static files?

2011-11-23 Thread Ivo Brodien
show your myapp.views.py file and is it the 
(r'^home/$','myapp.views.homepage'),

which is not working?

Is it showing the html source that you expect just not rendered or something 
else?

It is always a good idea to provide as much details as possible.

But yeah, we are getting close.

cheers
Ivo



> Gah!  Removed it, but now when I load up the page, it just shows me HTML 
> source code.  The rest of the views work fine.  
> 
> Sorry for all this trouble.  But at least something is happening with each 
> change you suggest!  I now have more hope than I've had in quite a while.  I 
> think we're getting close! =)
> 
> thanks,
> Guillaume
> 
> On Wed, Nov 23, 2011 at 8:08 PM, Ivo Brodien  wrote:
> you did not read the post by Tom Evans, did you? ;)
> 
> remove "django.core.context_processors.tz”,
> 
> or just put:
> 
> ("django.contrib.auth.context_processors.auth",
> "django.core.context_processors.debug",
> "django.core.context_processors.i18n",
> "django.core.context_processors.media",
> "django.core.context_processors.static",
> "django.contrib.messages.context_processors.messages")
> 
> 
> It was a mistake by me. I posted the one from the dev version.
> 
> does it work now?
> 
> 
> 
> On Nov 23, 2011, at 13:02 , Guillaume Chorn wrote:
> 
>> Hi,
>> 
>> Thanks for continuing to follow up on this.  Something is definitely 
>> happening now.  I went ahead and put this into my views.py:
>> 
>> from django.shortcuts import render
>> 
>> def items(request):
>> item_list=Item.objects.all()
>> return render(request, 'myapp/items.html', {'item_list':item_list},
>> content_type="text/css")
>> 
>> And now when I try to load the page, I get the following error:
>> 
>> ImproperlyConfigured at /diseases/
>> 
>> Module "django.core.context_processors" does not define a "tz" callable 
>> request processor
>> 
>> Request Method: GET
>> Request URL: http://127.0.0.1:8000/diseases/
>> Django Version: 1.3.1
>> Exception Type: ImproperlyConfigured
>> Exception Value: 
>> 
>> Module "django.core.context_processors" does not define a "tz" callable 
>> request processor
>> 
>> Exception Location: 
>> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/context.py
>>  in get_standard_processors, line 154
>> Python Executable: 
>> /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
>> Python Version: 2.7.2
>> Python Path: 
>> 
>> ['/Users/guillaumechorn/Documents/pharmapipe',
>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
>>  
>> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
>>  
>> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
>>  
>> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
>>  
>> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages']
>> Did something happen to my context.py file?  Here it is:
>> 
>> 
>> http://dpaste.com/660778/
>> 
>> Also, as you can see from the error message above, I am currently using 
>> Django 1.3.1.
>> 
>> 
>> thanks,
>> Guillaume
>> 
>> 
>> On Wed, Nov 23, 2011 at 7:10 PM, Ivo Brodien  wrote:
>> Hi,
>> 
>> STATIC_URL is not working in your template because the template does not get 
>> the RequestContext, which has all the variables in it.
>> 
>> use the render shortcut [1] instead of render_to_reponse
>> 
>> BTW: It seems you are using the development version. You should change to 
>> 1.3.1
>> 
>> Does this help?
>> 
>> [1]  https://docs.djangoproject.com/en/1.3/topics/http/shortcuts/#render
>> 
>> 
>> On Nov 23, 2011, at 7:33 , Guillaume Chorn wrote:
>> 
>>> Hi,
>>> 
>>> The location of my CSS file is 
>>> /Users/guillaum

Re: How-to for static files?

2011-11-23 Thread Ivo Brodien
you did not read the post by Tom Evans, did you? ;)

remove "django.core.context_processors.tz”,

or just put:

("django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.contrib.messages.context_processors.messages")


It was a mistake by me. I posted the one from the dev version.

does it work now?



On Nov 23, 2011, at 13:02 , Guillaume Chorn wrote:

> Hi,
> 
> Thanks for continuing to follow up on this.  Something is definitely 
> happening now.  I went ahead and put this into my views.py:
> 
> from django.shortcuts import render
> 
> def items(request):
> item_list=Item.objects.all()
> return render(request, 'myapp/items.html', {'item_list':item_list},
> content_type="text/css")
> 
> And now when I try to load the page, I get the following error:
> 
> ImproperlyConfigured at /diseases/
> 
> Module "django.core.context_processors" does not define a "tz" callable 
> request processor
> 
> Request Method: GET
> Request URL: http://127.0.0.1:8000/diseases/
> Django Version: 1.3.1
> Exception Type: ImproperlyConfigured
> Exception Value: 
> 
> Module "django.core.context_processors" does not define a "tz" callable 
> request processor
> 
> Exception Location: 
> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/context.py
>  in get_standard_processors, line 154
> Python Executable: 
> /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
> Python Version: 2.7.2
> Python Path: 
> 
> ['/Users/guillaumechorn/Documents/pharmapipe',
>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
>  
> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
>  
> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
>  
> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
>  
> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages']
> Did something happen to my context.py file?  Here it is:
> 
> http://dpaste.com/660778/
> 
> Also, as you can see from the error message above, I am currently using 
> Django 1.3.1.
> 
> 
> thanks,
> Guillaume
> 
> 
> On Wed, Nov 23, 2011 at 7:10 PM, Ivo Brodien  wrote:
> Hi,
> 
> STATIC_URL is not working in your template because the template does not get 
> the RequestContext, which has all the variables in it.
> 
> use the render shortcut [1] instead of render_to_reponse
> 
> BTW: It seems you are using the development version. You should change to 
> 1.3.1
> 
> Does this help?
> 
> [1]  https://docs.djangoproject.com/en/1.3/topics/http/shortcuts/#render
> 
> 
> On Nov 23, 2011, at 7:33 , Guillaume Chorn wrote:
> 
>> Hi,
>> 
>> The location of my CSS file is 
>> /Users/guillaumechorn/Documents/project/myapp/static/stylesheet.css.  Sorry, 
>> I may have missed you asking for this earlier.
>> 
>> Here is my views.py:
>> 
>> http://dpaste.com/660653/
>> 
>> When I hardcode the disk location of the CSS file in the template (like so: 
>> > href="/Users/guillaumechorn/Documents/project/myapp/static/stylesheet.css" 
>> type="text/css" />), the CSS shows up if I open the template file directly 
>> using a browser.  But it still doesn't show up when loading up the page on 
>> the development server.
>> 
>> thanks,
>> Guillaume
>> 
>> On Wed, Nov 23, 2011 at 9:57 AM, Ivo Brodien  wrote:
>> Hi,
>> 
>> looks fine.
>> 
>> yes, show your views.py 
>> 
>> and you can also hardcode the STATIC_URL in the template to see if the path: 
>> src=“/static/stylesheet.css” works.
>> 
>> or simply open http://127.0.0.1:8000/static/stylesheet.css in your browser.
>> 
>> Again: Where is that CSS file on your disk?
>> 
>> On Nov 23, 2011, at 2:46 , Guillaume Chorn wrote:
>> 
>>> Sor

Re: 'function' object has no attribute 'as_view'

2011-11-23 Thread Ivo Brodien
does this work?

...
(r"magasin/(?P\d+)/evenement/new/$",EvenementCreateView.as_view(model=Evenement,)),
...


I haven’t used Class based Views yet, but everytime they  show up in the docs 
it is always without using the url function and giving a name. So this is just 
a wild guess.

It seems like it is interpreting EvenementCreateView as a view function not as 
a class and does not let you call as_view.

The error happens always because django looks at all the urls you configured in 
order to know which one to use, this is why it always crashes.




On Nov 23, 2011, at 12:03 , youpsla wrote:

> Hello,
> the issue here seems to be trivial, maybe I got something in my eyes,
> but I can't find the solution.
> 
> Here is my code:
> 
> urls.py
> url(r"magasin/(?P\d+)/evenement/new/$",
> EvenementCreateView.as_view(model=Evenement),
> name='new_evenement_magasin'),
> 
> views.py:
> class EvenementCreateView(CreateView):
>form_class = EvenementForm
>sucess_url = 'user_magasins'
> 
>def dispatch(self, *args, **kwargs):
>   bla bla bla 
> 
>def form_valid(self, form):
>   bl bla bla .
>   return HttpResponseRedirect(self.get_success_url())
> 
> 
> What is funny here is whatever url of the site I call, even one which
> doesn't use this view I've the error describe in the subject. The
> traceback point on the line of the urls.py.
> 
> I'm not python and django proof, but as far I know class blablabla()
> define a Class and not a function !!!
> 
> Does someone have an idea here ?
> 
> Regards
> 
> Alain
> 
> -- 
> 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.



Re: How-to for static files?

2011-11-23 Thread Ivo Brodien
Hi,

STATIC_URL is not working in your template because the template does not get 
the RequestContext, which has all the variables in it.

use the render shortcut [1] instead of render_to_reponse

BTW: It seems you are using the development version. You should change to 1.3.1

Does this help?

[1]  https://docs.djangoproject.com/en/1.3/topics/http/shortcuts/#render


On Nov 23, 2011, at 7:33 , Guillaume Chorn wrote:

> Hi,
> 
> The location of my CSS file is 
> /Users/guillaumechorn/Documents/project/myapp/static/stylesheet.css.  Sorry, 
> I may have missed you asking for this earlier.
> 
> Here is my views.py:
> 
> http://dpaste.com/660653/
> 
> When I hardcode the disk location of the CSS file in the template (like so: 
>  href="/Users/guillaumechorn/Documents/project/myapp/static/stylesheet.css" 
> type="text/css" />), the CSS shows up if I open the template file directly 
> using a browser.  But it still doesn't show up when loading up the page on 
> the development server.
> 
> thanks,
> Guillaume
> 
> On Wed, Nov 23, 2011 at 9:57 AM, Ivo Brodien  wrote:
> Hi,
> 
> looks fine.
> 
> yes, show your views.py 
> 
> and you can also hardcode the STATIC_URL in the template to see if the path: 
> src=“/static/stylesheet.css” works.
> 
> or simply open http://127.0.0.1:8000/static/stylesheet.css in your browser.
> 
> Again: Where is that CSS file on your disk?
> 
> On Nov 23, 2011, at 2:46 , Guillaume Chorn wrote:
> 
>> Sorry, I think I made something confusing.  In my original file, I only 
>> pasted the URL pattern for the site homepage.  However, this is not the page 
>> I'm trying to style (or link to the CSS file).  The page I'm trying to link 
>> to the CSS file is a separate one, which I have previously referred to as 
>> http://127.0.0.1:8000/view/, but which I will hereafter refer to as 
>> http://127.0.0.1:8000/items/ (and will now include below).  I previously 
>> used the term "view" to imply a general myapp.views.view, but will hereafter 
>> refer to it as myapp.views.items.  Hope that makes sense.  I've used dpaste 
>> to share my code as suggested.
>> 
>> Here is my settings.py file:
>> 
>> http://dpaste.com/660563/
>> 
>> Here is the template which I want to style:
>> 
>> http://dpaste.com/660565/
>> 
>> And here is my urls.py file:
>> 
>> http://dpaste.com/660568/
>> 
>> Let me know if anything else is needed, such as the views.py file or 
>> something.
>> 
>> thanks,
>> Guillaume
>> 
>> On Wed, Nov 23, 2011 at 7:33 AM, Ivo Brodien  wrote:
>> In your original post you had the url like this:
>> 
>>> (r'^home/$','myapp.views.homepage'),
>> 
>> than your the url starts with view instead of home so there might be 
>> something wrong.
>> 
>> just paste these files into somthing like dpaste.com
>> 
>> - settings.py
>> - myapp.views.homepage
>> - urls.py
>> 
>> cheers
>> 
>> 
>> On Nov 23, 2011, at 0:29 , Guillaume Chorn wrote:
>> 
>>> Thank you Ivo.  Your suggestion makes a lot of sense so I tried it out.  
>>> Unfortunately, after adding TEMPLATE_CONTEXT_PROCESSORS and its associated 
>>> tuple into the settings.py file, I tried to restart the development server 
>>> to see if it worked and it didn't.  I checked the page source again and 
>>> it's still looking for /view/stylesheet.css.  Am I missing something else?
>>> 
>>> thanks,
>>> Guillaume
>>> 
>>> On Tue, Nov 22, 2011 at 10:42 PM, Ivo Brodien  wrote:
>>> 
>>>> Finally, I have another question.  In my settings.py file, there is 
>>>> actually no section for TEMPLATE_CONTEXT_PROCESSORS.  I have noticed in 
>>>> the documentation
>>> 
>>> yes.
>>> 
>>> put this in there:
>>> 
>>> ("django.contrib.auth.context_processors.auth",
>>> "django.core.context_processors.debug",
>>> "django.core.context_processors.i18n",
>>> "django.core.context_processors.media",
>>> "django.core.context_processors.static",
>>> "django.core.context_processors.tz",
>>> "django.contrib.messages.context_processors.messages")
>>> 
>>> and try again.
>>> 
>>> What happens in your template is that {{ STATIC_URL }} is empty because the 
>>> context processor ““django.core.context_processors.static”” did not put the 
>>> STATIC_URL into the context. so your path to the file becomes: 
>>> /view/stylesheet.css instead of /static/stylesheet.css
>>> 
>>> You have to put the CSS file in a directory called static as mentioned 
>>> 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.



Re: Django : CSRF and variable handling in a view

2011-11-23 Thread Ivo Brodien

> What about passing a variable set to False ? Should I still pass it
> like so :
> return render(request,'index.html', {'form': form,
> 'has_account':False})
> Or is it useless to pass it ?

Since you hardcode it to be False, yes it useless also to check in the template.

If the variable is missing a "if" in the template will evaluate to False.

If the template is used by other views which could provide has_account =True it 
should be in there, of course!



> 
> 
> On Nov 23, 5:02 am, DrBloodmoney  wrote:
>> On Tue, Nov 22, 2011 at 6:54 PM, Nolhian  wrote:
>>> Hello,
>> 
>>> I've got a subscription form and this view :
>> 
>>> def index(request):
>>>c = RequestContext(request)
>>>if request.user.is_authenticated():
>>>return render_to_response('index.html', {'has_account': 
>>> True})
>>>if request.method == 'POST':
>>>form = SignupForm(request.POST,error_class=DivErrorList)
>>>if form.is_valid():
>>>return HttpResponseRedirect('/thanks/')
>>>else:
>>>form = SignupForm()
>>>return render_to_response('index.html', {'form': form, 'has_account':
>>> False}, c)
>> 
>>> 1) In Index.html I have a form with a {% csrf_token %}. If I don't put
>>> c = RequestContext(request) and add the c into every
>>> render_to_response I've got a csrf error. Is my view above the right
>>> way to handle csrf ?
>> 
>>> 2) I noticed that instead putting
>>> c = RequestContext(request) *at the beginning of my view*
>>> and :
>>> return render_to_response('index.html', {'form': form, 'has_account':
>>> False}, c) *at the end of my view*
>> 
>>>  I could just put this at the end of my view :
>> 
>>> c = RequestContext(request, {'has_account': False,'form': form})
>>> return render_to_response('index.html', c)
>> 
>>> Which one it the best approach ?
>> 
>>> 3) I also noticed that if i don't pass 'has_account': False to my
>>> template, nothing changes, it still evaluate it as false in {% if
>>> has_account %}. Is it best to pass it to the template anyway ?
>> 
>>> Thanks in advance,
>> 
>>> Nolhian
>> 
>>> --
>>> 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 
>>> athttp://groups.google.com/group/django-users?hl=en.
>> 
>> Just use the render [1] shortcut. It'll put the RequestContext in for you.
>> 
>> [1]https://docs.djangoproject.com/en/1.3/topics/http/shortcuts/#render
> 
> -- 
> 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.



Re: How-to for static files?

2011-11-22 Thread Ivo Brodien
Hi,

looks fine.

yes, show your views.py 

and you can also hardcode the STATIC_URL in the template to see if the path: 
src=“/static/stylesheet.css” works.

or simply open http://127.0.0.1:8000/static/stylesheet.css in your browser.

Again: Where is that CSS file on your disk?

On Nov 23, 2011, at 2:46 , Guillaume Chorn wrote:

> Sorry, I think I made something confusing.  In my original file, I only 
> pasted the URL pattern for the site homepage.  However, this is not the page 
> I'm trying to style (or link to the CSS file).  The page I'm trying to link 
> to the CSS file is a separate one, which I have previously referred to as 
> http://127.0.0.1:8000/view/, but which I will hereafter refer to as 
> http://127.0.0.1:8000/items/ (and will now include below).  I previously used 
> the term "view" to imply a general myapp.views.view, but will hereafter refer 
> to it as myapp.views.items.  Hope that makes sense.  I've used dpaste to 
> share my code as suggested.
> 
> Here is my settings.py file:
> 
> http://dpaste.com/660563/
> 
> Here is the template which I want to style:
> 
> http://dpaste.com/660565/
> 
> And here is my urls.py file:
> 
> http://dpaste.com/660568/
> 
> Let me know if anything else is needed, such as the views.py file or 
> something.
> 
> thanks,
> Guillaume
> 
> On Wed, Nov 23, 2011 at 7:33 AM, Ivo Brodien  wrote:
> In your original post you had the url like this:
> 
>> (r'^home/$','myapp.views.homepage'),
> 
> than your the url starts with view instead of home so there might be 
> something wrong.
> 
> just paste these files into somthing like dpaste.com
> 
> - settings.py
> - myapp.views.homepage
> - urls.py
> 
> cheers
> 
> 
> On Nov 23, 2011, at 0:29 , Guillaume Chorn wrote:
> 
>> Thank you Ivo.  Your suggestion makes a lot of sense so I tried it out.  
>> Unfortunately, after adding TEMPLATE_CONTEXT_PROCESSORS and its associated 
>> tuple into the settings.py file, I tried to restart the development server 
>> to see if it worked and it didn't.  I checked the page source again and it's 
>> still looking for /view/stylesheet.css.  Am I missing something else?
>> 
>> thanks,
>> Guillaume
>> 
>> On Tue, Nov 22, 2011 at 10:42 PM, Ivo Brodien  wrote:
>> 
>>> Finally, I have another question.  In my settings.py file, there is 
>>> actually no section for TEMPLATE_CONTEXT_PROCESSORS.  I have noticed in the 
>>> documentation
>> 
>> yes.
>> 
>> put this in there:
>> 
>> ("django.contrib.auth.context_processors.auth",
>> "django.core.context_processors.debug",
>> "django.core.context_processors.i18n",
>> "django.core.context_processors.media",
>> "django.core.context_processors.static",
>> "django.core.context_processors.tz",
>> "django.contrib.messages.context_processors.messages")
>> 
>> and try again.
>> 
>> What happens in your template is that {{ STATIC_URL }} is empty because the 
>> context processor ““django.core.context_processors.static”” did not put the 
>> STATIC_URL into the context. so your path to the file becomes: 
>> /view/stylesheet.css instead of /static/stylesheet.css
>> 
>> You have to put the CSS file in a directory called static as mentioned 
>> 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.



Re: How-to for static files?

2011-11-22 Thread Ivo Brodien
In your original post you had the url like this:

> (r'^home/$','myapp.views.homepage'),

than your the url starts with view instead of home so there might be something 
wrong.

just paste these files into somthing like dpaste.com

- settings.py
- myapp.views.homepage
- urls.py

cheers


On Nov 23, 2011, at 0:29 , Guillaume Chorn wrote:

> Thank you Ivo.  Your suggestion makes a lot of sense so I tried it out.  
> Unfortunately, after adding TEMPLATE_CONTEXT_PROCESSORS and its associated 
> tuple into the settings.py file, I tried to restart the development server to 
> see if it worked and it didn't.  I checked the page source again and it's 
> still looking for /view/stylesheet.css.  Am I missing something else?
> 
> thanks,
> Guillaume
> 
> On Tue, Nov 22, 2011 at 10:42 PM, Ivo Brodien  wrote:
> 
>> Finally, I have another question.  In my settings.py file, there is actually 
>> no section for TEMPLATE_CONTEXT_PROCESSORS.  I have noticed in the 
>> documentation
> 
> yes.
> 
> put this in there:
> 
> ("django.contrib.auth.context_processors.auth",
> "django.core.context_processors.debug",
> "django.core.context_processors.i18n",
> "django.core.context_processors.media",
> "django.core.context_processors.static",
> "django.core.context_processors.tz",
> "django.contrib.messages.context_processors.messages")
> 
> and try again.
> 
> What happens in your template is that {{ STATIC_URL }} is empty because the 
> context processor ““django.core.context_processors.static”” did not put the 
> STATIC_URL into the context. so your path to the file becomes: 
> /view/stylesheet.css instead of /static/stylesheet.css
> 
> You have to put the CSS file in a directory called static as mentioned 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.



Re: How-to for static files?

2011-11-22 Thread Ivo Brodien
Does your generated HTML source say:



??

In your settings the TEMPLATE_CONTEXT_PROCESSORS

should have:

“django.core.context_processors.static”

The CSS File should go into a folder: myapp/static/stylesheet.css

> urlpatterns += staticfiles_urlpatterns()

I think you don’t need this. If you have the static app in your INSTALLED_APPS, 
it does this for you because it overrides te runserver command.

good luck

On Nov 22, 2011, at 11:16 , Gchorn wrote:

> Oh yes, I definitely have this in my INSTALLED_APPS list (as simply
> 'myapp').  Sorry I left it out; I thought this was necessary
> regardless of whether or not I was using static files, so I didn't
> include it in the list of settings I changed just to enable static
> files.   I do want to reiterate that I followed the tutorial closely
> in creating my project so I already have pretty much anything from
> there.
> 
> Any other ideas?
> 
> thanks,
> Guillaume
> 
> On Nov 22, 2:47 pm, Xavier Ordoquy  wrote:
>> Hi,
>> 
>>> What follows are my current settings.  In settings.py, I have:
>> 
>>> STATIC_URL = '/static/'
>>> INSTALLED_APPS = ('django.contrib.staticfiles',)
>> 
>> In order to get their static files served, apps need to be listed in the 
>> INSTALLED_APPS list.
>> As you don't mention it, you probably need to add myapp in the 
>> INSTALLED_APPS.
>> 
>> Regards,
>> Xavier,
>> Linovia.
> 
> -- 
> 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.



Re: How-to for static files?

2011-11-22 Thread Ivo Brodien
>> "django.core.context_processors.tz",
> 
> ISTR that this context processor (tz) only exists in trunk. So if he
> puts this literal block in, he will almost certainly have other
> issues.

True. sorry, since this is the default it should be there anyways. my mistake. 
And yes, it was copied accidentally from the dev docs.

Can the OP provide the myapp.views.homepage view?


-- 
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: How-to for static files?

2011-11-22 Thread Ivo Brodien

> Finally, I have another question.  In my settings.py file, there is actually 
> no section for TEMPLATE_CONTEXT_PROCESSORS.  I have noticed in the 
> documentation

yes.

put this in there:

("django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.tz",
"django.contrib.messages.context_processors.messages")

and try again.

What happens in your template is that {{ STATIC_URL }} is empty because the 
context processor ““django.core.context_processors.static”” did not put the 
STATIC_URL into the context. so your path to the file becomes: 
/view/stylesheet.css instead of /static/stylesheet.css

You have to put the CSS file in a directory called static as mentioned 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.



Re: Editable datagrid

2011-11-21 Thread Ivo Brodien


> Can't this be done in django itself? Without resorting to java, ajax
> and other fancy stuff?

Yes, it does. Did you try the tutorials? the admin is probably what you are 
looking for but should only be used by staff. 

-- 
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: copy entire data base to another host

2011-11-20 Thread Ivo Brodien
Hi,

no problem.

> Thanks a lot. Yes this is definitely an option if source and target host
> the same database engine.
> 
> 
> The reason why would I like to avoid this approach and why I tried to
> stick with django commands is, that above approach  will not work if I
> want to dump a postgres database to a test machine which has only sqlite
> or mysql.
> 
> Therfore my motivation was to use dumpdata and loaddata of manage.py

I was doing the same before, too: Having different DBs on dev machine and 
server. Because it was so much trouble maintaining the two using dumpdata and 
loaddata I ended up using the same DB on both machines which is also a good 
idea if you don’t want to run into any other surprises which are provoked by 
different DBs.

> Concerning above approach for mysql:
> 
> I think it is not necessary to provide the password in the command
> line. If I remember well one can create a temp file with permissions 600
> and store the user/password in it
> and specify it on the command line with
> --defaults-file=tmp_my.cnf

absolutely right. I even have that file and forgot to use it when I looked up 
the command in web.

> However as I don't use postgres that much I don't know whether postgres
> can do the same (specify a non default config file)

I bed it does. Just look around a little.

BTW: This testmachine should even have the same webserver as the real server so 
your testing is actually a little more accurate.

Bye and good luck

-- 
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: copy entire data base to another host

2011-11-20 Thread Ivo Brodien
hi,

on MYSQL I just do this to copy a MySQL DB to my local machine which runs in 
MAMP on Mac OS X.

Something similar should be possible with PostgreSQL as well.

ssh USERNAME@SERVER "mysqldump -u USERNAME_REMOTE -p'DB_PASSWORD_REMOTE' 
--single-transaction DB_NAME | gzip -c" | gunzip -c | 
/Applications/MAMP/Library/bin/mysql -u USERNAME_LOCAL -p'DB_PASSWORD_LOCAL’ 
DB_NAME

Since the password is provided on the command line it should only be run on a 
system with a single user.

bye
Ivo



On Nov 20, 2011, at 19:09 , Gelonida N wrote:

> On 11/20/2011 06:37 PM, Gelonida N wrote:
>> Hi,
>> 
>> I for debugging purposes I'd like to clone the data base of one machine
>> to another one. (both are not necessarily using the same data base engine)
>> 
>> What would be the suggested procedure?
>> 
>> What I tried, but what failed is following:
>> 
>> 1.) On the remote machine
>> ./manage.py dumpdata > dumpall.json
>> 
>> 2.) copy dumpall.json to remote machine
>> 
>> 3.) On the machine to be cloned to:
>> ./manage.py flush
>> ./manage.py loaddata dumpall.json
>> 
>> The error, that I get is:
>> 
>> IntegrityError: duplicate key value violates unique constraint
>> "django_content_type_app_label_key"
>> 
>> 
>> The only ideas, that I have are:
>> - delete all conflicting tables from the source host before applying my
>> fixture (I would do the with ./manage.py shell or with a tiny script)
>> 
>> - dump all apps except the ones causing problems.
>> 
>> Thanks a lot in advance for any suggestion.
>> 
>> 
>> 
> What I did now is following (this time the source and destination
> database were both postgres)
> 
> 
> 
> 1.) On the remote machine
> ./manage.py dumpdata > dumpall.json
> 
> 2.) copy dumpall.json to remote machine
> 
> 3.) On the machine to be cloned to:
> ./manage.py sqlflush
> copy the truncate statement from the output to the clipboard
> ./manage.py dbshell
> enter the password and paste the truncate statement and quite the db shell
> 
> ./manage.py loaddata dumpall.json
> 
> 
> This is working, but not that nice to automate,
> as the SQL snippet, that I have to extract from sqlflush
> depends on the db engine and as I have to be sure, that I have to create
> a .pgpass entry for postgres in order to avoid the password prompt.
> 
> 
> 
> 
> 
> -- 
> 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.



Re: Custom admin changelist queryset

2011-11-18 Thread Ivo Brodien
Both Bar and Foo obviously have a featured table and are somehow very common 
since you want them to be displayed in on list - which also  makes only sense 
if they share the same attributes cause otherwise you would have empty columns 
depending on the model of the row your are showing.

Maybe Bar and Foo should inherit from a common Model?

To me it seems like your models are not defined well.

Also, to show only items which have featured = True you can use a Filter 
(list_filter) in the admin and not create a special admin.

cheers
Ivo





On Nov 18, 2011, at 15:43 , bax...@gretschpages.com wrote:

>> Can you tell us what you goal here is?
> 
> The goal is to get my combined list of featured items to a changelist
> page. From there, I'll have additional work to do, but step one is
> getting it to the page at all.
> 
> Another thought is to just chain the querysets together and send 'em
> to my own template. It would look like part of the admin, but not
> actually be part of the admin. Problem there, of course, is that if I
> wanted actions, list display, or any other admin-y goodness, I'd be
> out of luck, I think.
> 
> 
>>> I'm trying to combine a subset of two models and pass them to an admin
>>> change list:
>> 
>>> class FeaturedItemsAdmin(admin.ModelAdmin):
>>>   def queryset(self, request):
>>>   qs1 = Foo.objects.filter(featured=True)
>>>   qs2 = Bar.objects.filter(featured=True)
>>>  . do stuff to combine ...
>>>  return combined
>> 
>>> I can return qs1 or qs2 to the admin, no problem. But I can't put them
>>> together in a way the admin will accept.
>> 
>>> First thing I tried was a simple itertools.chain. I've also tried
>>> building a custom queryset (http://djangosnippets.org/snippets/1933/)
>>> and subclassing queryset. At best, I get nothing, but most times I
>>> get:
>> 
>>> "Database error
>>> Something's wrong with your database installation. Make sure the
>>> appropriate database tables have been created, and make sure the
>>> database is readable by the appropriate user."
>> 
>>> Which I've tracked down to a IncorrectLookupParameters exception in
>>> contrib.admin.options, but that doesn't really help me figure out what
>>> it is the admin wants that I'm not giving it.
>> 
>>> --
>>> 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 
>>> athttp://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.



Re: Custom admin changelist queryset

2011-11-17 Thread Ivo Brodien
Well the admin.ModelAdmin expects to be working, for one model only (knowing 
about its table structure).

Can you tell us what you goal here is?

Probably you want to show more information than there is in one model?

You can create methods in your model and use them to show more information like 
this in a "BarAdmin":

class BarAdmin(admin.ModelAdmin):
list_display = ['more_info']

def more_info(self,obj):
return self.foo.name
more_info.allow_tags = True # to show HTML tags
more_info.short_description = ‘More Info’ #a nicer name

admin.site.register(Bar,BarAdmin)

How did you register your FeaturedItemsModelAdmin?

Bye
Ivo

On Nov 17, 2011, at 21:11 , bax...@gretschpages.com wrote:

> I'm trying to combine a subset of two models and pass them to an admin
> change list:
> 
> class FeaturedItemsAdmin(admin.ModelAdmin):
>   def queryset(self, request):
>   qs1 = Foo.objects.filter(featured=True)
>   qs2 = Bar.objects.filter(featured=True)
>  . do stuff to combine ...
>  return combined
> 
> 
> I can return qs1 or qs2 to the admin, no problem. But I can't put them
> together in a way the admin will accept.
> 
> First thing I tried was a simple itertools.chain. I've also tried
> building a custom queryset (http://djangosnippets.org/snippets/1933/)
> and subclassing queryset. At best, I get nothing, but most times I
> get:
> 
> "Database error
> Something's wrong with your database installation. Make sure the
> appropriate database tables have been created, and make sure the
> database is readable by the appropriate user."
> 
> Which I've tracked down to a IncorrectLookupParameters exception in
> contrib.admin.options, but that doesn't really help me figure out what
> it is the admin wants that I'm not giving it.
> 
> 
> 
> -- 
> 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.



Re: controlling user access

2011-11-17 Thread Ivo Brodien
Do you want to use the admin for administration? You should not, since the 
admin is designed to be used by people that can be trusted, although it can be 
done, by overriding queryset method of the ModelAdmin.

As stated before, make a page where a user selects the business and afterwards 
you query the articles for that business. This can be done in one or different 
views.

Bye

On Nov 17, 2011, at 9:13, Mario Gudelj  wrote:

> Hi Djangoers,
> 
> I have a problem on my hands I'm not sure how to approach and would 
> appreciate your guidance.
> 
> I'm building a site that will host articles for separate businesses and each 
> business will have a user who needs to log in and administer article that 
> only belong to a particular business.
> 
> So, I have the following model:
> 
> class Business(models.Model):
> id = models.AutoField(primary_key=True)
> name = models.CharField("Business Name", max_length=50, blank=False)
> slug = models.SlugField("Slug", max_length=255, unique=True, blank=False)
> 
> 
> class StaffProfile(models.Model):
> user = models.ForeignKey(User, unique=True)
> 
> id = models.AutoField(primary_key=True)
> 
> business = models.ManyToManyField(Business)
> 
> 
> class Article(models.Model):
> id = models.AutoField(primary_key=True)
> business = models.ForeignKey(Business, null=False)
> 
> 
> So, every business will have a separate subdomain and will have a unique 
> slug. 
> 
> Users can belong to one or more businesses and my StaffProfile extends the 
> Django's user class.
> 
> What I don't know is how to authenticate a user into a particular business, 
> so that this user only has access to the business they are logged into.
> 
> What I want them to do is to choose which business they want to log into on 
> the login and once they enter the username, password and select the business 
> I want them to be able to access articles that only belong to that business 
> and none of the articles that belong to those other businesses.
> 
> Any help or suggestions will be highly appreciated. Thanks guys!
> 
> Mario 
> 
> 
> -- 
> 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.



Re: Manage exception from external services in a form

2011-11-16 Thread Ivo Brodien
Hi,

As stated in the answer on SO you should write a custom clean method for your 
field.

Bye

On Nov 16, 2011, at 5:31, youpsla  wrote:

> Sorry,
> 
> I've not search enough,
> 
> I think this post : 
> http://stackoverflow.com/questions/6365318/custom-field-error-from-try-except-in-django-view
> 
> give me the solution . but one question left, can I do this
> solution in the form_valid part of my class ... I'll try ...
> 
> Regards
> 
> Alain
> 
> On 16 nov, 05:08, youpsla  wrote:
>> Hello,
>> I hope, despite my poor english, to be enough clear.
>> 
>> In my Django app, users fill a form with adress, Zip, CIty
>> informations.
>> 
>> I like to geocode those informations to fill the lat and lng field of
>> the table db. FOt this tak I use geocoders method from geopy module.
>> It works fine if Google doesn't raise an error.
>> 
>> If I got an error ("GQueryError"), I like my Django app refresh to the
>> form page (Has it's the case for example in case of an empty field
>> with no blank=True option) and show an error message to the user
>> explaining him I can't geocode him blablabla 
>> 
>> My App is organize like this:
>> 
>> - A model with all fields I talk about above
>> - I use the generic base view (CreateView)
>> - The geocoding take place in the form_valid(self,form) function in my
>> pesonnal overriding class of CreateView.
>> 
>> Hope there is enough informations  .
>> 
>> Help will be really appreciated. Of course feel free to ask all
>> informations you want.
>> 
>> Regards
>> 
>> Alain
> 
> -- 
> 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.



Re: Why does collectstatic finds static files in admin 'media' directory?

2011-11-15 Thread Ivo Brodien
Thanks Phil!

that should really be in the docs!

bye

On Nov 15, 2011, at 17:38 , Philip Mountifield wrote:

> I found this a little while ago and reported the mistake in the docs. There 
> is an exception made in the code for the admin media to preserve backwards 
> compatibility, and allow the files to remain in "media" rather than "static".
> 
> Regards
> Phil
> 
> On 15/11/2011 16:34, Ivo Brodien wrote:
>> Hi,
>> 
>> on 1.3.1. I ran:
>> 
>> ./manage.py collectstatic --dry-run
>> 
>> and it found files in: django/contrib/admin/media/
>> 
>> which is fine, but I am wondering, why these files are found since the docs 
>> says, that the default folder apps have to store there static assets is a 
>> folder called “static”.
>> 
>> I haven’t added anything to STATICFILES_DIRS or STATICFILES_FINDERS
>> 
>> Thanks for clarification.
>> 
>> PS: I am upgrading from 1.2.5 to 1.3.1 so my setting.py file is actually an 
>> "old one”  with the added settings for the static stuff.
> 
> 
> -- 
> 
> Philip Mountifield
> Formac Electronics Ltd
> tel  +44 (0) 1225 837333
> fax  +44 (0) 1225 430995
> 
> pmountifi...@formac.net
> www.formac.net
> www.telgas.net
> 
> -- 
> 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.



Why does collectstatic finds static files in admin 'media' directory?

2011-11-15 Thread Ivo Brodien
Hi,

on 1.3.1. I ran:

./manage.py collectstatic --dry-run

and it found files in: django/contrib/admin/media/

which is fine, but I am wondering, why these files are found since the docs 
says, that the default folder apps have to store there static assets is a 
folder called “static”.

I haven’t added anything to STATICFILES_DIRS or STATICFILES_FINDERS

Thanks for clarification.

PS: I am upgrading from 1.2.5 to 1.3.1 so my setting.py file is actually an 
"old one”  with the added settings for the static stuff.

smime.p7s
Description: S/MIME cryptographic signature


Re: Automatically direct unauthenticated users to homepage

2011-11-15 Thread Ivo Brodien
Hi,

these views are protected by @login_required view, right?

If so, users that are not logged in should be redirected to the login view.

If you are not using the decorator, how are you handling users that are not 
logged in these different views? You are probably doing something against the 
DRY principle.

bye
Ivo

On Nov 15, 2011, at 17:16 , CrabbyPete wrote:

> I have a site with lots of views. When someone comes to my site and is
> not logged in I direct them to the homepage to login. However a user
> could type in a whole url for a view and it will go there and cause an
> error because the view expects the user to be logged in. I could put
> logic in every view to see if the user is logged in but it seems
> redundant. Is there a way to force anonymous users to the home even if
> they type in a full url to a specific view
> 
> -- 
> 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.
> 



smime.p7s
Description: S/MIME cryptographic signature


Re: What's the best way to display user information in the base template?

2011-11-15 Thread Ivo Brodien
Hi,

you are basically asking how views and templates work in django.

I suggest start with the django tutorials [1] and then you will understand that 
what you are trying to do is nothing special.

You might want to use a decorator called “@login_required” vor your views which 
show user info. This way you don’t have to check yourself, if a user is logged 
in or not.


Good luck and fun in learning django.

[1] https://docs.djangoproject.com/en/dev/intro/tutorial01/


On Nov 15, 2011, at 15:45 , Levi Campbell wrote:

> I'm trying to create a base template that would display user-specific
> information such as an avatar and the number of unread messages a user
> has, what's the best way to do this? I know by reading the
> documentation that I can check if a user is logged in, which is a
> start, but doesn't fully answer my question. Searching Google only
> points me back to the django documentation and to examples, none of
> them fit the bill. Thank you for your time and have a great day.
> 
> -- 
> 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.
> 



smime.p7s
Description: S/MIME cryptographic signature


Re: Network configuration with django webpage

2011-11-12 Thread Ivo Brodien
You will  have to make some system calls from your django views (in python of 
course)

Cheers

On Nov 12, 2011, at 6:22, Ganesh Kumar  wrote:

> Hi guys,
> 
> I am new to django, I want to create a simple page to configure
> network configuration,
> to configure ip address and set submask and gateway configuration.
> 
> How to do with django, any clues and please guide me.
> 
> -Ganesh.
> Did I learn something today? If not, I wasted it.
> 
> -- 
> 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.



Re: models.FileField versus forms.FileField

2011-11-10 Thread Ivo Brodien
Hi,

> But to clarify it seems like the forms.fileField can be used in a model in 
> place of models.filefield, as in the code below.

> class UploadFileForm(forms.Form):
>title = forms.CharField(max_length=50)
>file  = forms.FileField()

In your code you are using only forms, no models involved.

MyModel(models.Model)
file  = forms.FileField()

will not work for example.

> Is there some advantage to the formsHandleUpload


you obviously don’t have to write the code yourself for writing the file to the 
filesystem.

But if this is form is somehow connected to a model you would have write the 
path to that file (and other stuff) into the DB yourself.

Cheers
Ivo

smime.p7s
Description: S/MIME cryptographic signature


Re: Editing objects from the admin site isn't working

2011-11-09 Thread Ivo Brodien
Can you see the edits in your DB?

Did you write code for the admin of that model yourself ?

On Nov 9, 2011, at 17:05, Tim Ogilvie  wrote:

> I'm running into a problem editing from the admin site. I'm able to
> successfully create new objects but edits aren't being saved. There
> are no error messages given - it looks like the changes were
> successful but those changes aren't "taking".
> 
> I've seen some chatter that suggests it may relate to the fact that I
> have two foreignkeys inline, but nothing that sounds exactly like my
> problem.
> 
> Is there a way that I can diagnose what is going wrong? There's no
> error messaging or other details to point me in the right direction.
> Or is there a clear write-up on how the admin site would treat editing
> objects in a different way from creating new ones?
> 
> -- 
> 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.



Re: models.FileField versus forms.FileField

2011-11-09 Thread Ivo Brodien
Hi,

well they are different things.

models.FileField is used to define a field of a model (usually to store in a 
DB, metadata in this case)

The forms.FileField defines a field in a HTML form which can receive File 
uploads and then can be used to do sth on the server.

I think you will get the concept when you take a look at ModelForms. These are 
forms which are tied to a model and can even be automatically be generated as 
in the admin app. If you have a model with a FileField this ModelForm will have 
a forms.FileField for the FileField.

in a few words:
A models.FileField knows about database options, a forms.FileField knows about 
HTML and how it has to be rendered via its widget.

Bye
Ivo

On Nov 8, 2011, at 3:16, Eli_West  wrote:

> Hello,
> 
> When creating a working with the models and views to upload files what
> is the difference between models.FileField and forms.FileField? Just a
> practical usage explanation would be good at this point.
> 
> i can't find any comparison of the two but django directions and
> examplesh use one or the other. I've gotten forms that use
> models.FileField calls to work but the forms.FileField seems to act
> up. For example this general django directions use the
> form.fileField:
> 
> from django import forms
> 
> class UploadFileForm(forms.Form):
>title = forms.CharField(max_length=50)
>file  = forms.FileField()
> 
> def upload_file(request):
>if request.method == 'POST':
>form = UploadFileForm(request.POST, request.FILES)
>if form.is_valid():
>handle_uploaded_file(request.FILES['file'])
>return HttpResponseRedirect('/success/url/')
>else:
>form = UploadFileForm()
>return render_to_response('upload.html', {'form': form})
> 
> def handle_uploaded_file(f):
>destination = open('some/file/name.txt', 'wb+')
>for chunk in f.chunks():
>destination.write(chunk)
>destination.close()
> 
> All the chunks() calls and others seem helpful but the
> models.FileField ( upload to = /somedir)   gets things done in a snap.
> 
> Any recommendations?
> 
> -- 
> 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.



Re: Django as a Standalone Desktop Application

2011-10-21 Thread Ivo Brodien
Hi,

> Could you tell us more about the utility you want to create?  It sounds like 
> Django might not be the appropriate tool in this case.

well it is quite simple.

The user will have to provide some metadata for every week of the year. This 
then gets printed to a monthly view with the 4 weeks of the month +/- a few 
days of that month

A downloadable PDF file will be created which then has to be filled out with 
more data. This "more data” might be entered via the online interface one day, 
but that is not sure at all.

I think with django this is an easy tast.

This might loos like a typical Excel/VBA and maybe Word thing, but I don’t want 
to use non open source software for this and since I like Django and there it 
might be the feature of a online input of the data I want to go with Django.

What would you recommend?




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



Django as a Standalone Desktop Application

2011-10-21 Thread Ivo Brodien
Hi,

I want to write a little utility for somebody and I would like to use Django to 
develop it.

At the moment the utility does not need/or never will have to be running on a 
web server.

I would like to build a little standalone desktop app, so that I can send the 
Django App and everything that is needed (Python,MySQL/SqLite) with one 
Installer/Folder for Windows.

Searching google I found “dbuilder.py”

Looks like what I am looking for, but I was wondering if you have any 
experience or suggestions. Maybe there is a newer tool or some state-of-the-art 
way to do it? dbuilder.py was last updated in 2008.

Something like XAMMP or MAMP with support for python and mysqldb would be nice.

Thanks!

PS: I am developing on Mac OS X but could use a virtualized Windows if there is 
need.

-- 
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: Creating simple view app based on Admin site

2011-06-24 Thread Ivo Brodien
Some time ago I ran into similar questions and what I found out is:

the bottom line:

the admin is intended for admins and stuff, not users. That is people you 
trust, so you should never enable admin access for regular users.

So I guess you are on the right way with copying from the admin views and 
templates.


Ivo


On Jun 24, 2011, at 2:27 AM, Alexei wrote:

> Hi,
> 
> I'm trying to create a simple application whose most important feature
> is going to be to view/search the contents of my database.  I have the
> Admin site configured to exactly how I want the end product to look
> (searching, filtering, etc.) but I'm having trouble porting this over
> to the user (public) side of the app.  I figured I would just subclass
> the Admin classes, or just straight-up copy and paste the Admin code
> and modify it from there, but it turned out to not be so simple.
> 
> What's the easiest way to display the database to the end-user the
> same way that the Admin interface does (without edit capabilities)?
> It feels like such a waste to write everything from scratch when I
> have what I want the end product to look like right in front of me.
> 
> -Alexei
> 
> -- 
> 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.



Re: django 1.3 timing out on empty POST request

2011-06-24 Thread Ivo Brodien

On Jun 24, 2011, at 2:40 AM, mehdi ait oufkir wrote:

> block = getattr(request, POST, { })


shouldn’t it be:


block = getattr(request, ‘POST', { }) ?

What are you trying to do? Can you post the rest of the view function?



-- 
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: Field Type for S3 Storage?

2011-06-16 Thread Ivo Brodien
>  How does the |mageField know the dimensions of the image?

Nevermind.

Just saw that the file gets opened for the dimension by looking at the source 
code.

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



Field Type for S3 Storage?

2011-06-16 Thread Ivo Brodien
hello,

I am planing a django application, which manages photos that are stored in a S3 
Bucket.

With boto and django-storages I can declare an ImageField and images get 
uploaded to S3 easily.

But I want to make a mobile client use an API to upload photos directly to S3 
(using signed Forms) and tell the django app about the uploaded file. This way 
I can take off load of the server.

The validation of a API form expects the actual image data in the POST request. 
I can prevent an error by changing the form validation but what about the 
height and width attributes if I only store the path of the file in the DB? How 
does the |mageField know the dimensions of the image?

Thanks
Ivo 




-- 
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: syncdb doesn't create UserProfile table

2011-06-16 Thread Ivo Brodien
> In the paragraph preceding this link it explicitly states to use
> OneToOneField. The Django documentation is canonical, if it says one
> thing, and elsewhere on the internet says something else, the internet
> is wrong. The internet is often wrong.
> 
> The difference between a ForeignKey(unique=True) and OneToOneField is
> that on the reverse side of the relationship, the one-to-one is
> represented as a single attribute on the instance, where as the
> foreign key is represented as an object manager.

thanks. I did not read carefully. And of course, django docs is what I rely on 
in the first place.

they are just great and easy to read.

-- 
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: syncdb doesn't create UserProfile table

2011-06-16 Thread Ivo Brodien

>> Actually, I've read that ForeignKey is now the way to specify it. 
> 
> unique foreign key *was* the correct way as onetoone was broken. This is
> no longer true.

where is the most up to date info on this?

In the dev docs about storing additional user info on djangoproject.com there 
is a link to an old Django Book 

Chapter 12 of the Django book

there it says: 

 user = models.ForeignKey(User, unique=True)

This Django Book however is old and in the new one in Chapter 14: Sessions, 
Users, and Registration the User Profile does not get mentioned anymore.

Also the first search result in google for “django user profile” is James 
Bennetts blog entry where he also uses Foreign Key.

What is the difference between Foreign Key (unique= true) and a OneToOne field 
anyway?

Thanks! 

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



Should/Can I use API methods for other views? (django-piston)

2011-06-16 Thread Ivo Brodien
I was wondering if I can/should access the API methods I use with django-piston.

Lets say I want to get some objects belonging to a user in the read API method.

On a web request that does not use the API call but is a simple request from a 
browser client should my view than call the read method of the handler so i 
don’t repeat myself?

Or should I even make another method which will be called by the APIs read 
method and my other view which serves html?

Probably the latter, right? Now that I think of it, this method could probably 
be one of a custom Manager for my model.

thanks for clarification


-- 
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: syncdb doesn't create UserProfile table

2011-06-16 Thread Ivo Brodien
an idea: Do you have a __init__.py  in every subfolder? also the models and 
userprofile folder under calltracking_main ?


On Jun 16, 2011, at 10:10 AM, Benedict Verheyen wrote:

> Hi,
> 
> 
> The syncdb command doesn't want to create the UserProfile table.
> Also when I was trying to get this working while running the app,
> it was complaining about AUTH_PROFILE_MODULE.
> It is however correctly specified in my settings.py:
> ...
> AUTH_PROFILE_MODULE = 'calltracking_main.UserProfile'
> ...
> Installed apps is ok:
> INSTALLED_APPS = (
>'django.contrib.auth',
>...
> 'calltracking.calltracking_main',
> )
> 
> model:
> class UserProfile(models.Model):
>class Meta:
>verbose_name = _('UserProfile')
>verbose_name_plural = _('UserProfiles')
>db_table = 'calltracking_userprofile'
>ordering = ('displayname',)
>app_label = 'calltracking'
>displayname = models.CharField(max_length=50)
>department = models.CharField(max_length=30, blank=True)
>user = models.ForeignKey(User, unique=True)
>def __unicode__(self):
>return self.displayname
> 
> As I split models, I have to specify this in the __init__.py file:
> ...
> from calltracking_main.models.userprofile import UserProfile
> ...
> 
> I don't know if this is relevant, but here's my wsgi:
> import sys
> import os
> 
> apache_dir = os.path.dirname(os.path.abspath(__file__))
> project_dir = os.path.normpath(os.path.join(apache_dir + '/../..'))
> app_dir = os.path.normpath(os.path.join(apache_dir + '/..'))
> 
> sys.path = [
>os.path.join(project_dir, 'lib/python2.7/site-packages'),
>project_dir,
>app_dir
>] + sys.path
> 
> os.environ['DJANGO_SETTINGS_MODULE'] = 'calltracking.settings'
> 
> import django.core.handlers.wsgi
> application = django.core.handlers.wsgi.WSGIHandler()
> 
> 
> So syndb doesn't pick up on the UserProfile, what am I doing wrong?
> Can I force recreation of the model? I have delete the whole db but still no 
> luck.
> I upgraded Django (tracking trunk) but that wasn't a sollution either.
> 
> Weird thing is that this code is a fork from another project (very minor 
> differences)
> and there, I didn't encounter any errors.
> Both projects run on virtualhosts specified in apache with 
> wsgi/nginx/memcached,
> from a virtualenv.
> 
> Thanks for any info,
> 
> Regards,
> Benedict
> 
> -- 
> 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.



Re: unique constraint

2011-06-15 Thread Ivo Brodien
https://docs.djangoproject.com/en/1.3/ref/models/options/#unique-together

On Jun 15, 2011, at 9:40 AM, Tobias Ottenweller wrote:

> hi,
> 
> a had a look at the django documentation but I could not find a way to do 
> something like this in django:
> 
> 
> CREATE TABLE test_table (
>id integer,
>name text
> );
> 
> ALTER TABLE ONLY test_table
>ADD CONSTRAINT test_table_id_name_key UNIQUE (id, name);
> 
> 
> Is there a way to put a constraint like this in django model class?
> 
> -- 
> 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.



Printing admin is strange except in Safari

2011-06-15 Thread Ivo Brodien
Hello,

I have an admin action which produces a table of selected items. I used the 
admin base_site template so I have the ability to go back easily.

I did:

{% extends "admin/base_site.html" %}

...

{% block content %}






{% for participant in participants %}
...
   {% endfor %}


The problem is that the table rows at the beginning of the page get printed 
over with the header from the admin on every page except the first one. I don’t 
know why the admin header gets printed on all of the pages anyways.

IE and Firefox are doing this.

The problem does not occur on Safari (tested on Mac only).

Does anyone know where this behavior come from and how to avoid it?

thanks





-- 
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: GET vs POST for read-only views

2011-06-14 Thread Ivo Brodien


> thanks - in 15 years of web programming I have never used get - maybe
> time to start now.

??

that would mean, that none of your website was ever reachable by entering the 
URL in a browser. Remember: all links you put on a webpage will be GET requests 
made by the browser, when you click on them.



-- 
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: imagefield problem .....

2011-06-13 Thread Ivo Brodien
> On Jun 13, 2011, at 5:57 PM, Pankaj Singh wrote:
> 
>> yes even in get_image_url it will be
>> 
>> return os.path.join(settings.MEDIA_URL, 'news', 
>> self.image.name.split('/')[-1])

> 


writing that function is not necessary.

from: https://docs.djangoproject.com/en/dev/ref/models/fields/#filefield

> 3) All that will be stored in your database is a path to the file (relative 
> to MEDIA_ROOT). You'll most likely want to use the convenience url function 
> provided by Django. For example, if your ImageField is called mug_shot, you 
> can get the absolute path to your image in a template with {{ 
> object.mug_shot.url }}.


so the Pulkit was trying in his template is ok, he just should use the url 
function and the MEDIA_URL

-- 
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: imagefield problem .....

2011-06-13 Thread Ivo Brodien

On Jun 13, 2011, at 12:52 PM, Pulkit Mehrotra wrote:

> problem in using the address stored in imagefield

you should describe your problem a little better!

But I guess the URL is not working?

You shouldn’t use STATIC_URL but MEDIA_URL for the prefix in your template.

STATIC_URL is for static files, that don’t change like CSS and JS.

MEDIA_URL is for user uploads, like a photo in your news entry.

-- 
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: How to disable security hash in django comments

2011-06-06 Thread Ivo Brodien
search for csfr excempt decorator.

On Jun 6, 2011, at 4:35 PM, Ján Vorčák wrote:

> Hi,
> 
> I'd like to ask you about one problem.
> I need to remove security hash django comments module. I need to allow
> posting to my app from external application just by posting the post
> request.
> How can I do that? Is there any way to disable this "security hash"
> protection?
> 
> 
> 
> Thank you
> 
> -- 
> 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.



Re: Need some help with MySQL and on OSX

2011-06-06 Thread Ivo Brodien


> MAMP. about as easy as it can get.
> http://www.mamp.info/de/index.html

But you will still need to install somehow MySQLdb and that is the main problem.

I don’t know about homebrew, but I remember that I had troubles getting MySQLdb 
to work but I eventually did with the help of various blogs and Stack Overflow 
posts, unfortunatelly I did not write down the steps, so good luck. I hope 
homebrew is a one click solution.

-- 
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: How to create user on mobile app for Django site?

2011-06-02 Thread Ivo Brodien
Hey Malcom,

thanks for the answer. Glad, I was more or less on right way.


>> How would I authenticate against the Django site?
> 
> Your choices are either to use username/passwords or OAuth. If you're using 
> username/passwords you can hook straight into the standard Django 
> authentication - just have your code do a POST to /admin/login with 
> username/password. That's not massively secure, so you might want to consider 
> doing it over SSL.

Of course SSL for clear text passwords, but why would I want to use the 
“/admin/login”? I think only staff can login under this URL. And wouldn’t I get 
a CSRF error anyway doing a POST  request out of nothing?

> 
>> When I use URL connections from the mobile app do I always have to send the 
>> credentials or can the Django site identify me by storing session cookies on 
>> the client just like as if the mobile app would be a browser?
>> 
> You can use session cookies just as on the desktop - the iPhone NSURLRequest 
> will handle cookies for you. This is true on most platforms, the only place 
> I've found where it doesn't work consistently is on Flash.

Good to know!

I have some questions about using OAUTH. As I understand OAUTH is good for when 
I want to give 3rd party access to the users data via my API without having the 
users give away their password to that 3rd party. I could consider my iPhone 
App a third party but I would still have to authorize against my Django Server 
to get the token. So if I don’t really want to open the API to a 3rd party 
there is no sense to use OAUTH? Using cookies and Django auth will be 
equivalent since with Django auth I would be sending a session-cookie where 
with OAUTH i would be sending the access_token in the URL so basically the same 
thing, isn’t it?

If I want my users to use another OAUTH provider to identify on my Django site 
there are solutions like Janrain and Gigya which cost a lot of money. And there 
is among others django-socialauth which is open source. If see it right the 
service from Janrain and Gigya is to unify the whole process with all the 
providers ad thus saving time in writing all the code one self. But why do they 
charge so much?

Cheers
Ivo 


-- 
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: How to create user on mobile app for Django site?

2011-05-31 Thread Ivo Brodien
Thanks for sharing your opinion!

Your approach is probably good for many website/applications, but since I want 
to make use of InApp Purchases and Camara Overlays and Custom Controls, I don’t 
think this is the right way to go.

I was impressed by PhoneGap though... 2 or 3 years ago I was seeing their 
affords which where great, but know it seems to have gotten quite big in terms 
of features and system support.

thanks

> My approach would be to:
> 
> 1) Build a regular site using django-registration and django-profiles
> to handle signups, passwords as usual.
> 
> 2) Build an HTML mobile site off of that (you need one anyway, even if
> you're going to have an app). There are lots of tutorials out there on
> delivering mobile versions of content with Django.
> 
> 3) Use something like Sencha or Phonegap to compile the mobile site as
> iPhone and Android apps.

-- 
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: How to I create download link of some file using django

2011-05-31 Thread Ivo Brodien
you are welcome!

> I have another question here. It seems that django.contrib.staticfiles
> can be used to handle some static files during the 'debug' mode while
> using the embedded 'runserver' from django. However, would it be
> possible if I just develop my website using the system's Apache and
> not using the django.contrib.staticfiles?

Of course and this is even better, because this is how the setup should be on 
real server.

You have to configure Apache to serve for example everything under 
http://mydomain.com/static/ as a simple file without talking to django at all. 
The static stuff is good for static files like CSS and JavaScript.

BTW:  although this goes beyond the question I just want to mention it for 
completeness.

On the other hand the {{MEDIA_URL }} and MEDIA_ROOT is more for server/user 
generated files. You can still have Apache serve the file after authorizing it 
against Django. The keyword here is: x-sendfile

http://stackoverflow.com/questions/1156246/having-django-serve-downloadable-files

What you were doing with open the file probably only makes sense if you need to 
 process the contents of the file in any way. 


-- 
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: How to I create download link of some file using django

2011-05-31 Thread Ivo Brodien

> I am a bit confused about how to set the MEDIA_URL variable here.
> Currently, I am testing the web using Django embedded webserver and
> doesn't have a proper url yet. Should my MEDIA_URL be something
> like... http://my_machine_name:8000/media/


yes, but so in your template you do:

> ### in the template 


> download


Your:
> http://groups.google.com/group/django-users?hl=en.



Re: How to I create download link of some file using django

2011-05-31 Thread Ivo Brodien
Hi did you read this documentation about serving static files?

In generally you don’t want serve files through django, but through your actual 
webserver (e.g. Apache, nginx, lighttpd...).

However during development you can make django serve them.

See: Serving static files in development

https://docs.djangoproject.com/en/dev/howto/static-files/

Since it can become a bit cumbersome to define this URL pattern, Django ships 
with a small URL helper function static() that takes as parameters the prefix 
such as MEDIA_URL and a dotted path to a view, such as 
'django.views.static.serve'. Any other function parameter will be transparently 
passed to the view.
An example for serving MEDIA_URL ('/media/') during development:


from django.conf import settings
from django.conf.urls.static import static



urlpatterns = patterns('',


# ... the rest of your URLconf goes here ...
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

cheers


On May 31, 2011, at 4:24 PM, Kann wrote:

> Dear all,
> 
> I am a bit confused about how to set the MEDIA_URL variable here.
> Currently, I am testing the web using Django embedded webserver and
> doesn't have a proper url yet. Should my MEDIA_URL be something
> like... http://my_machine_name:8000/media/
> 
> Kann
> 
> On May 26, 12:42 pm, Boštjan Mejak  wrote:
>> Fix   some_file  = open('bla/bla/bla/', "rw")tosome_file  =
>> open('bla/bla/bla/', "r")
>> 
>> Fix that "rw" to just "r". You just want the user to read (a.k.a. get) the
>> file, not have write access to it.
> 
> -- 
> 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.



How to create user on mobile app for Django site?

2011-05-31 Thread Ivo Brodien
What is the correct way to do the following:

1) Mobile App from which a user can create a user/profile on the Django site
2) Allow authenticated users to create on the site and query personalized data 
from the site

This is what I guess I have to do:

1) Create a REST API  (probably with e.g. django-piston) on at the Django site 
for creation and authentication 

How would I authenticate against the Django site?

When I use URL connections from the mobile app do I always have to send the 
credentials or can the Django site identify me by storing session cookies on 
the client just like as if the mobile app would be a browser?

Note: When I say mobile app I actually mean iPhone App for now, but there might 
be a Android version sometime in the future.

Thanks for any advice!




-- 
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: Caught KeyError while rendering: u'objects_name'

2011-02-13 Thread Ivo Brodien
Hi,

when the admin is deleting an object it gathers a list (calling all unicode 
methods) of other foreign key objects and displays them as a warning that they 
will also be deleted.
I think the error occurs in:

> class Disposition (models.Model):
>  []
>def __unicode__(self):
>return self.name

try to return u’foo’ to see if the errors still occurs!

BTW: method names should be lowercase

(http://www.python.org/dev/peps/pep-0008/)


On 13.02.2011, at 23:52, Bobby Roberts wrote:

> when i try to delete one of the TractorRecord objects in this model, i
> get this message:
> 
> Caught KeyError while rendering: u'objects_name'
> 
> any idea what that means?
> 
> Django 1.2.3 (mod_wsgi 3.2/Python 2.6)
> 
> 
> 
> 
> # this holds possible dispositions for Tractoruees
> class Disposition (models.Model):
>id = models.AutoField (primary_key=True)
>name = models.CharField (max_length=50, blank=False,
> db_index=True)
>active = models.IntegerField(blank=False,
> choices=active_choices)
>order = models.IntegerField(blank=True, default=0)
> 
>def __unicode__(self):
>return self.name
> 
> class DispositionAdmin(admin.ModelAdmin):
>list_display = ('name','active','order',)
>search_fields = ['name']
> 
> 
> admin.site.register(Disposition,DispositionAdmin)
> 
> #this holds the Tractor information
> class TractorRecord (models.Model):
>id = models.AutoField (primary_key=True)
>FirstName = models.CharField (max_length=25,blank=False,
> db_index=True)
>LastName = models.CharField (max_length=45,blank=False,
> db_index=True)
>Status = models.CharField
> (choices=inout_choices,max_length=3,blank=False, db_index=True)
>Photo= models.ImageField(upload_to="Tractoruees/", blank=True)
>Disposition = models.ForeignKey('Disposition',
> verbose_name=_('Disposition Value'),db_index=True, blank=False)
>Notes = models.TextField(blank=True)
>LastTouchedBy = models.ForeignKey(User, unique=False,
> db_index=True, blank=False)
>LastUpdated = models.DateTimeField
> (auto_now_add=True,blank=False, db_index=True,help_text='Auto Filled')
> 
>def disposition_name(self):
>return self.Disposition.name
> 
>def Last_Updated_By(self):
>return self.LastTouchedBy.get_full_name()
> 
>#resize uploaded image to max 650 x 650
>def save(self, size=(175,175)):
>super(TractorRecord, self).save()
>if self.Photo:
>filename = self.Photo.path
>image = Image.open(filename)
>image.thumbnail(size, Image.ANTIALIAS)
>image.save(filename)
> 
> class TractorRecordAdmin(admin.ModelAdmin):
>list_display =
> ('Picture','FirstName','LastName','Status','disposition_name','Last_Updated_By','LastUpdated')
>search_fields = ['FirstName','LastName','LastTouchedby']
> 
>def Picture(self,instance):
>return '' %
> (instance.Photo)
>Picture.allow_tags=True
> 
> admin.site.register(TractorRecord,TractorRecordAdmin)
> 
> -- 
> 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.



Re: Admin URL validation too strict?

2011-02-10 Thread Ivo Brodien
I just checked and my admin accepts (and correctly validates it) the port 
inside a URL.

In django.core.validators.py you can see, that the port is accepted.





On 10.02.2011, at 22:55, ringemup wrote:

> 
> Er, Correction
> 
> It's not an anchor that's causing problems, but a port specification
> -- e.g. http://www.example.com:81/example.html
> 
> On Feb 10, 4:45 pm, ringemup  wrote:
>> I've been trying to use the Django admin to moderate spam comments,
>> but it appears that the URL validation is stricter in the admin (i.e.
>> in the default ModelForm) than in the comment posting form.
>> 
>> Any URL with an anchor in it 
>> (i.e.http://www.example.com/example.html#whatever)
>> passes validation for comment posting but raises a validation error in
>> the admin.  As a result, my users can't edit and save an object that
>> has a comment with such a URL as an inline unless they edit the anchor
>> out of the URL.  Not all of my users understand how to edit a URL to
>> remove the anchor, either.
>> 
>> Is this a bug in Django?  Is there an easy workaround?
> 
> -- 
> 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.



new Admin class for each pre-filtered change list?

2011-02-09 Thread Ivo Brodien
I am using the following code, so that I can have different change lists that 
depend on some variable. The way the stuff member does not have to manually 
apply the filter each time he/she enters the list:


class CourseApplicationAdminS12(CourseParticipantAdmin):
year = 2012
def queryset(self, request):
req = super(CourseApplicationAdminS12, self).queryset(request)
return req.filter(course__period__start_date__year = self.year)
class Meta:
verbose_name_plural = _('Participant Summer 2012')
verbose_name = _('Participants Summer 2012’)

class CourseApplicationAdminS13(CourseParticipantAdmin):
year = 2013
def queryset(self, request):
req = super(CourseApplicationAdminS13, self).queryset(request)
return req.filter(course__period__start_date__year = self.year)
class Meta:
verbose_name_plural = _('Participant Summer 2013')
verbose_name = _('Participants Summer 2013')

def create_modeladmin(modeladmin, model, name = None):
class  Meta:
proxy = True
app_label = model._meta.app_label

attrs = {'__module__': 'applications', 'Meta': Meta}

newmodel = type(name, (model,), attrs)
admin.site.register(newmodel, modeladmin)
return modeladmin

create_modeladmin(CourseApplicationAdminS12, name='Participation Summer %i' % 
2012, model=CourseApplication)
create_modeladmin(CourseApplicationAdminS13, name='Participation Summer %i' % 
2013, model=CourseApplication)


as you can see, I am creating a ModelAdmin and some proxy model and all that 
differs it actually the name and the year attibute of the AdminClass, which 
gets used in queryset to filter the objects.

This seems like a lot of coding for such a simple task. It works but seems not 
to be right !?

Another idea that just comes to my mind is to have the filter in the Get 
parameter and make links available in the admin interface?

Thanks!

-- 
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: imported tuples/variables don't get translated

2011-02-08 Thread Ivo Brodien
hey Marcos,

> Are you doing: from django.utils.translation import ugettext_lazy as _ ?
> or: from django.utils.translation import ugettext as _ ?
> 
> The first one shoud work.

Indeed I used ugettext instead of ugettext_lazy

Thanks!

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



imported tuples/variables don't get translated

2011-02-08 Thread Ivo Brodien
If I import some tuple which is used for choices in a forms.RadioSelect widget, 
then the choices don’t get translated

models.py:

BOOL_CHOICES = ((True, _(u'Yes')), (False, _(u'No')))

forms.py:

from models import BOOL_CHOICES

1) does work an translates the choices
form.fields['accomdation'].widget = forms.RadioSelect(choices = ((True, 
_(u’Yes')), (False, _(u'No'

2) does not translate the choices
form.fields['accomdation'].widget = forms.RadioSelect(choices = BOOL_CHOICES)


something similar happens for a label

STATIC = _(u”mystring”)

...label = STATIC does not work
...label = _(STATIC) does work


Is this a bug or a desired behavior or am I missing something?

-- 
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: model names

2011-02-06 Thread Ivo Brodien

On 06.02.2011, at 18:01, Bobby Roberts wrote:

> yeah i tried that already and it didn't work

did you also define the meta class for the Admin class?

-- 
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: user full name in template

2011-02-04 Thread Ivo Brodien

> Don't forget the login_required decorator, because if an anonymous
> user try to get that page he will get an exception (I think, didn't
> try that)

No, they will be redirected to login and after login they come back to the 
original page, if the form considers the ’next’ field. How nice is that!?

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



Delete/Update Memcache in 1.2.4?

2011-02-03 Thread Ivo Brodien
Which key is used in 1.2.4 to create the memcache keys?

I am having some html in my database whose keys I want to delete from the 
memcache after they have been saved (or via admin actions)

I don’t know how to get their keys and even doing a cache.clear() in the action 
and console did not delete anything from the cache.

If I were using 1.3 I could just define my own keys using KEY_FUNCTION, but in 
1.2. I can’t do that.

Doing some telnet to memcach I found out that the keys are very long and that 
they include the path.to.view and some odd numbers (probably session keys or 
something)

How can I disable this behavior? For it would be fine, if the key was just 
‘/pages/about’

Thank you for helping (once again)





-- 
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: store superuser permamently

2011-02-03 Thread Ivo Brodien

> What do I have to do to avoid having to define a superuser each time?

you can dump the data of the auth app and than load it again.

s.th. like this:

./manage.py dumpdata --indent=4 auth  > fixtures/auth.json
./manage.py dumpdata --indent=4 sessions >  fixtures/sessions.json

you can do a manage.py syncdb —noinput so you will not be asked, if you want a 
superuser or not.

If you dump the sessions too you will stay logged in.

-- 
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: Memcache configured, but not used !?

2011-02-03 Thread Ivo Brodien

On 03.02.2011, at 13:38, Tom Evans wrote:

> You don't specify what version of django you are using. I suspect you
> are referring to the trunk/1.3 docs, and using 1.2. In 1.2, the cache
> is controlled by settings.CACHE_BACKEND, which defaults to locmem if
> omitted.

You are right I am using 1.2.4 (see my previous answer).

Now it seems, that the cach is working although the cache-debug-panel shows 
every values as being 0, but I can tell by the SQL query panel that the 
datebase wasn’t hit.

Just saw that the caches debug panel is not really working:
http://code.google.com/p/django-debug-toolbar/issues/detail?id=13

thanks for helping me out!

-- 
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: Memcache configured, but not used !?

2011-02-03 Thread Ivo Brodien

On 03.02.2011, at 13:39, Xavier Ordoquy wrote:

> I'm not sure it is.
> Can you make sure you are using django 1.3 ?
> in the shell do:
> import django
> print django.VERSION
> 
> If it says 1, 2, whatever, your configuration isn't correct as CACHES is for 
> 1.3
> 
> Xavier.

ahh! ok. I was looking at the 1.3 docs but using 1.2.4

I will try using : CACHE_BACKEND = 'memcached://127.0.0.1:11211/‘

Thanks a lot!

-- 
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: Memcache configured, but not used !?

2011-02-03 Thread Ivo Brodien
Hi!

> I assume you configured the cache backend to point to memcache, didn't you ?

yes :)

in my settings.py I have



   CACHES = {
   'default': {
   'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
   }
   }


try:
   from local_settings import *
except ImportError:
   pass

and in local_settings.py:

CACHES = {
   'default': {
   'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
   'LOCATION': '127.0.0.1:11211',
   }
}

Which should override the dummycache setting.

However I just checked using ./manage.py shell:

from django.core.cache import cache
print cache


In the shell it is using the locmem which I haven’t configured anywhere... 
strange!

Bye
Ivo

-- 
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 SQL Query does not stop

2011-02-03 Thread Ivo Brodien
Hi Chris,

thanks for the info. My tables won’t have many rows and I don’t have the time 
for optimazation, especially if it is not necessary, but I will keep your words 
in mind!

Cheers
Ivo


On 02.02.2011, at 06:10, Chris Matthews wrote:

> Hi Ivo,
> 
> SQL is like regular expressions. You can go complex (with one mega 
> query/expression) but it could create a maintenance nightmare. See if you 
> cannot simplify the query into multiple queries and a bit of code (for loops 
> and using the joining columns) to lash them together. The code sequence 
> should be such that you limit access to a huge amount of rows; so you filter 
> the data accessed. It is usually easier to debug as well. And using Tom's 
> advice (EXPLAIN SELECT ...) on smaller join queries is often more useful 
> (than the explain on a mega join query).
> 
> In my experience it often runs way faster if the query is simplified.
> 
> Regards
> Chris
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
> Behalf Of Ivo Brodien
> Sent: 01 February 2011 23:49
> To: django-users@googlegroups.com
> Subject: Re: Django SQL Query does not stop
> 
> I found a solution be changing the MySQL server setting 
> optimizer_search_depth to 3 (default 62)
> 
> http://dev.mysql.com/doc/refman/5.0/en/controlling-optimizer.html
> http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_optimizer_search_depth
> 
> My query had over 20 INNER JOINTS and it made the optimizer search a long 
> process.
> 
> So at the moment a value of 3 is fine.
> 
> On 01.02.2011, at 21:20, Ivo Brodien wrote:
> 
>> The Change List that I am calling is a Intermediate Table if that is of any 
>> interest.
>> 
>> Is it possible that there is some sort of circular inner joints or something?
>> 
>> 
> 
> -- 
> 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.
> 

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



Memcache configured, but not used !?

2011-02-03 Thread Ivo Brodien
I did the following to enable memcache:

1 ) install memcache and it is running with default values: /usr/bin/memcached 
-m 64 -p 11211 -u nobody -l 127.0.0.1

2) put a decorator over my view @cache_page(60 * 2)

3) enable cache panel in debug toolbar

The Problem is, that the edebug panel says 0 for all the cache values, so I 
suppose it is not used.

How can I debug this problem further?

I did not put any CacheMiddleware in settings.py cause I think this is not 
necessary with the per-view cache?

Thanks!

-- 
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 SQL Query does not stop

2011-02-01 Thread Ivo Brodien
I found a solution be changing the MySQL server setting optimizer_search_depth 
to 3 (default 62)

http://dev.mysql.com/doc/refman/5.0/en/controlling-optimizer.html
http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_optimizer_search_depth

My query had over 20 INNER JOINTS and it made the optimizer search a long 
process.

So at the moment a value of 3 is fine.

On 01.02.2011, at 21:20, Ivo Brodien wrote:

> The Change List that I am calling is a Intermediate Table if that is of any 
> interest.
> 
> Is it possible that there is some sort of circular inner joints or something?
> 
> 

-- 
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 SQL Query does not stop

2011-02-01 Thread Ivo Brodien
The Change List that I am calling is a Intermediate Table if that is of any 
interest.

Is it possible that there is some sort of circular inner joints or something?


-- 
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 SQL Query does not stop

2011-02-01 Thread Ivo Brodien

On 01.02.2011, at 16:55, Tom Evans wrote:

> In the mysql shell:
> 
> EXPLAIN SELECT ...

unfortunately same problem. CPU turns to 100% and it is stuck.

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



Django SQL Query does not stop

2011-02-01 Thread Ivo Brodien
When I am in admin and I access of a certain model, Django calls mysql with an 
Query which increases mysql CPU load to 99% and it never returns.

If I copy the the SQL Query right into mysql the same thing happens, so it is 
actually kind of a mysql problem, but since Django created the query, I thought 
I might get help here.

I did not call any select_related or something.

On my dev machine I am using sqlite and the same query does not cause any 
trouble and returns within 4 ms.

There are less not more than 5 rows in each table, so database size cannot be a 
problem.

Any ideas? where to start debugging this?



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



  1   2   >