Re: Django and Rails

2014-05-28 Thread Lachlan Musicman
Also, the community certainly doesn't seem to be fading to me -
between this list, SO and the IRC channel, there is lots of movement.

There is a new release every 6 months or so and the devs are pushing
security updates at about one every two months although that's more
dependent on when the security issues are discovered than running to a
plan.

I wouldn't fear the Django community disappearing anytime soon.

cheers
L.

On 29 May 2014 14:40, Lachlan Musicman  wrote:
> For db changes, you want South, although the author of South has just
> finished integrating it into Django 1.7.
>
> http://south.aeracode.org/
> http://south.readthedocs.org/en/latest/
> http://south.readthedocs.org/en/latest/tutorial/index.html
>
> Version 1.7 of Django, due any day now, will have migrations built in.
>
> cheers
> L.
>
> On 29 May 2014 13:55, Enrique Shadah  wrote:
>> Hi all,
>>
>> I am learning Django after trying once with Rails. As I am a newbie to
>> software development, Rails seemed more obscure and difficult to digest. I
>> chose to learn Django because Python is easier to understand than Ruby (at
>> least to me) and because I thought it had a bigger or more enthusiastic
>> community to learn from.
>>
>> However, I am finding that Django has some limitations Rails does not.  One
>> is that its community is fading (or at least it feels that way).  Another is
>> that Rails seems to be better at automating mundane tasks (staying true to
>> the DRY principle). For example, rake db migrate can add/subtract fields on
>> table without writing any sql.  Django can add fields and tables with
>> syncdb, but if I need to subtract fields or change whether the field is
>> required or not, I am faced to writing sql.  This seems pretty silly given
>> that new site is constantly changing, thus models will suffer many changes
>> as users suggest/reject features.
>>
>> These are just two limitations off the top of my head.  I am sure Django is
>> awesome, but could anyone share their views on whether I should just learn
>> Rails off the bat instead of going the Django then Rails route?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/228300d7-8e5a-4a9b-8165-45e33168cc7f%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> The idea is that a beautiful image is frameable. Everything you need
> to see is there: It’s everything you want, and it’s very pleasing
> because there’s no extra information that you don’t get to see.
> Everything’s in a nice package for you. But sublime art is
> unframeable: It’s an image or idea that implies that there’s a bigger
> image or idea that you can’t see: You’re only getting to look at a
> fraction of it, and in that way it’s both beautiful and scary, because
> it’s reminding you that there’s more that you don’t have access to.
> It’s now sort of left the piece itself and it’s become your own
> invention, so it’s personal as well as being scary as well as being
> beautiful, which is what I really like about art like that.
> ---
> Adventure Time http://theholenearthecenteroftheworld.com/



-- 
The idea is that a beautiful image is frameable. Everything you need
to see is there: It’s everything you want, and it’s very pleasing
because there’s no extra information that you don’t get to see.
Everything’s in a nice package for you. But sublime art is
unframeable: It’s an image or idea that implies that there’s a bigger
image or idea that you can’t see: You’re only getting to look at a
fraction of it, and in that way it’s both beautiful and scary, because
it’s reminding you that there’s more that you don’t have access to.
It’s now sort of left the piece itself and it’s become your own
invention, so it’s personal as well as being scary as well as being
beautiful, which is what I really like about art like that.
---
Adventure Time http://theholenearthecenteroftheworld.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 

Re: Django and Rails

2014-05-28 Thread Lachlan Musicman
For db changes, you want South, although the author of South has just
finished integrating it into Django 1.7.

http://south.aeracode.org/
http://south.readthedocs.org/en/latest/
http://south.readthedocs.org/en/latest/tutorial/index.html

Version 1.7 of Django, due any day now, will have migrations built in.

cheers
L.

On 29 May 2014 13:55, Enrique Shadah  wrote:
> Hi all,
>
> I am learning Django after trying once with Rails. As I am a newbie to
> software development, Rails seemed more obscure and difficult to digest. I
> chose to learn Django because Python is easier to understand than Ruby (at
> least to me) and because I thought it had a bigger or more enthusiastic
> community to learn from.
>
> However, I am finding that Django has some limitations Rails does not.  One
> is that its community is fading (or at least it feels that way).  Another is
> that Rails seems to be better at automating mundane tasks (staying true to
> the DRY principle). For example, rake db migrate can add/subtract fields on
> table without writing any sql.  Django can add fields and tables with
> syncdb, but if I need to subtract fields or change whether the field is
> required or not, I am faced to writing sql.  This seems pretty silly given
> that new site is constantly changing, thus models will suffer many changes
> as users suggest/reject features.
>
> These are just two limitations off the top of my head.  I am sure Django is
> awesome, but could anyone share their views on whether I should just learn
> Rails off the bat instead of going the Django then Rails route?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/228300d7-8e5a-4a9b-8165-45e33168cc7f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
The idea is that a beautiful image is frameable. Everything you need
to see is there: It’s everything you want, and it’s very pleasing
because there’s no extra information that you don’t get to see.
Everything’s in a nice package for you. But sublime art is
unframeable: It’s an image or idea that implies that there’s a bigger
image or idea that you can’t see: You’re only getting to look at a
fraction of it, and in that way it’s both beautiful and scary, because
it’s reminding you that there’s more that you don’t have access to.
It’s now sort of left the piece itself and it’s become your own
invention, so it’s personal as well as being scary as well as being
beautiful, which is what I really like about art like that.
---
Adventure Time http://theholenearthecenteroftheworld.com/

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


Django and Rails

2014-05-28 Thread Enrique Shadah
Hi all,

I am learning Django after trying once with Rails. As I am a newbie to 
software development, Rails seemed more obscure and difficult to digest. I 
chose to learn Django because Python is easier to understand than Ruby (at 
least to me) and because I thought it had a bigger or more enthusiastic 
community to learn from.

However, I am finding that Django has some limitations Rails does not.  One 
is that its community is fading (or at least it feels that way).  Another 
is that Rails seems to be better at automating mundane tasks (staying true 
to the DRY principle). For example, rake db migrate can add/subtract fields 
on table without writing any sql.  Django can add fields and tables with 
syncdb, but if I need to subtract fields or change whether the field is 
required or not, I am faced to writing sql.  This seems pretty silly given 
that new site is constantly changing, thus models will suffer many changes 
as users suggest/reject features.  

These are just two limitations off the top of my head.  I am sure Django is 
awesome, but could anyone share their views on whether I should just learn 
Rails off the bat instead of going the Django then Rails route?

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


Re: virtualenv help needed

2014-05-28 Thread Lachlan Musicman
Two things:

1. Put your media local to your site - I use
/home/user/www/dj-project/static and
/home/user/www/dj-project/collected_media for project at
/home/user/www/dj-project/

2. The place you are referring to is inside the virtual env's little
jail. You can find that by using the cdsitepackages command when in
the venv. But you shouldn't really put your data in there. The Two
Scoops of Django book has a good example of choices available and then
good reasoning for the style they recommend. It's worth the read.

cheers
L.

On 29 May 2014 12:54, Kelvin Wong  wrote:
> Why are you placing user media in your /usr/local/.../dist-package
> directories? (Debian?)
>
> Wouldn't it make more sense to place them somewhere in /srv or /var?
>
> https://docs.djangoproject.com/en/1.6/howto/static-files/
>
> K
>
> On Wednesday, May 28, 2014 9:40:54 AM UTC-7, Deepak Sharma wrote:
>>
>> A year before I developed an applciation in django==1.4.5 version. Few
>> days before I installed virtualenv with django version 1.4.5. In my
>> application I have to place "media" folder inside
>> /usr/local/lib/[ython2.7/dist-package/django/contrib/admin/media but after
>> installating virtualenv I didn't find any django folder inside dist-package.
>> Can anyone help me out with this, how should I allocate proper path to it?
>>
>> Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/82e56ae6-3a52-4776-b307-de269997ac46%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
The idea is that a beautiful image is frameable. Everything you need
to see is there: It’s everything you want, and it’s very pleasing
because there’s no extra information that you don’t get to see.
Everything’s in a nice package for you. But sublime art is
unframeable: It’s an image or idea that implies that there’s a bigger
image or idea that you can’t see: You’re only getting to look at a
fraction of it, and in that way it’s both beautiful and scary, because
it’s reminding you that there’s more that you don’t have access to.
It’s now sort of left the piece itself and it’s become your own
invention, so it’s personal as well as being scary as well as being
beautiful, which is what I really like about art like that.
---
Adventure Time http://theholenearthecenteroftheworld.com/

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


Re: Custom user model backend

2014-05-28 Thread Kelvin Wong
In your settings.py you might have to set the SESSION_COOKIE_AGE

https://docs.djangoproject.com/en/1.4/topics/http/sessions/#session-cookie-age

K


On Wednesday, May 28, 2014 5:49:01 AM UTC-7, Domagoj Kovač wrote:
>
> Hi guys,
>
> I extended base user model with certain fields. My code is as follows:
>
> #!/usr/bin/env python
>> # -*- coding: utf-8 -*-
>> from django.utils import timezone
>> from django.conf import settings
>> from django.contrib.auth.backends import ModelBackend
>> from django.core.exceptions import ImproperlyConfigured
>> from django.db.models import get_model
>
>  
>
>  
>
> class CustomUserModelBackend(ModelBackend):
>> def authenticate(self, username=None, password=None):
>> try:
>> user = self.user_class.objects.get(username=username)
>> if user.login_duration is None or user.login_duration >= 
>> timezone.now():
>> if user.check_password(password):
>> return user
>> else:
>> return None
>> except self.user_class.DoesNotExist:
>> return None
>
>
>> def get_user(self, user_id):
>> try:
>> return self.user_class.objects.get(pk=user_id)
>> except self.user_class.DoesNotExist:
>> return None
>> @property
>> def user_class(self):
>> if not hasattr(self, '_user_class'):
>> self._user_class = 
>> get_model(*settings.CUSTOM_USER_MODEL.split('.', 2))
>> if not self._user_class:
>> raise ImproperlyConfigured('Could not get custom user 
>> model')
>> return self._user_class
>
>
> Everything works as it should but if i am logged in system logs me out 
> after certain time even i am using application. Is there something i missed 
> that controls how login persistence is handled?
>
> Best,
> Domagoj 
>
>

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


Re: Help - Django App on Heroku & local dev machine

2014-05-28 Thread Kelvin Wong
Clone the app locally

http://stackoverflow.com/questions/1872113/how-do-i-clone-a-github-project-to-run-locally

Create a virtualenv

http://virtualenv.readthedocs.org/en/latest/virtualenv.html#usage

Install your requirements

$ pip -r your_app_path/requirements.txt

Run the dev server

https://docs.djangoproject.com/en/1.6/ref/django-admin/#runserver-port-or-address-port

To get the code back on the machine, look for a fabfile and use it, or just 
push to origin and update it manually over SSH.

If you don't already know Python or Django, I'd recommend

http://www.diveintopython.net/

https://docs.djangoproject.com/en/1.6/intro/tutorial01/

K

On Wednesday, May 28, 2014 7:03:04 AM UTC-7, Dr Shauny wrote:
>
> Hi,
>
> I have a Django app already deployed and fully functional on Heroku. The 
> app was purchased from a third party that transferred the codebase via 
> github.
>
> I need to make changes and redeploy the app but understand that this is 
> not possible (or advisable) directly from github itself.
>
> I therefore need to set up a local development environment for the app 
> from where I can deploy changes to the github repository and also deploy 
> updates to the installation on Heroku.
>
> Heroku have an article that explains how to create a new app and upload 
> this to Heroku ("Getting started with Django on Heroku") , however many of 
> the details appear to be for a new app rather than for my situation where I 
> already have a fully functional app. I am unsure as to what I should and 
> shouldnt do as I am unclear about the relevancy of some of the instructions.
>
> Can anyone walk me through the process of transferring an app from github 
> to a local machine so that I can dev on the local machine. OS would be 
> ubuntu 12.04 and ideally want to set up dev and prod repos on github (and 
> eventually dev and prod apps on heroku). I believe I have done most of the 
> local work with postgres, python virtualenv, heroku and django toolbelts 
> etc, but would really appreciate an expert to bounce some queries off?
>
> Anyone able to help?
>
> S.
>

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


Re: virtualenv help needed

2014-05-28 Thread Kelvin Wong
Why are you placing user media in your /usr/local/.../dist-package 
directories? (Debian?)

Wouldn't it make more sense to place them somewhere in /srv or /var?

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

K

On Wednesday, May 28, 2014 9:40:54 AM UTC-7, Deepak Sharma wrote:
>
> A year before I developed an applciation in django==1.4.5 version. Few 
> days before I installed virtualenv with django version 1.4.5. In my 
> application I have to place "media" folder inside 
> /usr/local/lib/[ython2.7/dist-package/django/contrib/admin/media but after 
> installating virtualenv I didn't find any django folder inside 
> dist-package. Can anyone help me out with this, how should I allocate 
> proper path to it?
>
> Thank you.
>

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


Re: Anyone interested in reviewing the code of a small project - BookMarker

2014-05-28 Thread Aseem Bansal
Anyone interested in reviewing updated code? Now the search functionality 
is working. I have added comments and a link with screenshots of working 
functionality. Also  refactoring done in the Javascript to make code easier 
to read. I think the functionality should be clearer by the changed code 
now. I have added a partial for rendering as was suggested. 

There are some parts of code which can be improved but I don't know exactly 
how to implement the changes. 
Like the Javascript needs the static URL for addition of categories on 
screen. It can be done in a much better way if I can use a partial here. 
But I am not sure how to render a partial by the html() function of a 
javascript. Any ideas?

On Tuesday, May 27, 2014 8:26:20 PM UTC+5:30, Aseem Bansal wrote:
>
> Background? I have some experience(a few months only) with Java 6/Struts 
> 1.2 for web development. Started working on Python May 2013. Not 
> continuously but as a hobby for scripting purposes and some automation. I 
> guess my github and stackoverflow account can give you a better idea 
> https://github.com/anshbansal/general
> http://stackoverflow.com/users/2235567/aseem-bansal
>
> On Tuesday, May 27, 2014 7:09:47 PM UTC+5:30, shmengie wrote:
>>
>> Partials/sub-templates are the same.
>>
>> For a small one pager, includes aren't very useful.  As for the logic in 
>> using them, that's more difficult to elaborate since it depends a lot on 
>> the layout and design of the site. 
>>
>> There are a couple of different types of "sub sections" you can 
>> implement.  html fragments, which are useful in larger sites.  Then there 
>> are fragments of css/js which even tho it's all html, I refer to html as 
>> presentation code and css/js as links/includes.  For a larger site this is 
>> more useful, but since you're using this as a learning tool, why not 
>> implement concepts that are useful in larger sites.
>>
>> I referenced the custom tags, because you can dynamically include CSS & 
>> Javascript (partials) based on rules with them.  Which is a nifty concept, 
>> though I've seen it used, Ive not implemented them myself   I don't 
>> wish to push too much on your plate, w/out knowing your background, but 
>> this might be a good concept for you to tackle at this point.
>>
>>
>>

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


Re: Mysql DB local socket access errors with mod_wsgi

2014-05-28 Thread Henning Sprang
On Wed, May 28, 2014 at 3:18 PM,   wrote:
> It's very likely a permissions problem. Webserver processes tend to run under 
> a special username (e.g. www-data) with very limited permissions - it's 
> likely that this user does not have access to the socket file.

Yeah, that was the thing, thanks!

Actually I looked at the permissions, but the socket file had 777, but
the directory is 700 and owned by mysql:root.

If I experimentally chowned the directory to www-data and it works.
Which is strange as the mysql command line client connects via socket,
too when not given a hostname, I believe, and it works well when run
as a normal user.

Anyway, thanks for the pointer.

Henning

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


RE: [OT] Web application and image scanner

2014-05-28 Thread Ilya Kazakevich
Hello,

* Silverlight 
* JavaFX 
* Flash
* ActiveX (Windows only)


Ilya Kazakevich,
JetBrains PyCharm (Best Python/Django IDE)
http://www.jetbrains.com/pycharm/
"Develop with pleasure!"


>-Original Message-
>From: django-users@googlegroups.com
>[mailto:django-users@googlegroups.com] On Behalf Of Fabio C. Barrionuevo da
>Luz
>Sent: Wednesday, May 28, 2014 10:52 PM
>To: django-users@googlegroups.com
>Subject: [OT] Web application and image scanner
>
>Anyone know any client-side alternative to Java and Java Applets in a Web
>application to capture images from Network or USB scanner and send to server
>somehow (WebDAV, HTTP POST FILE, or other way)?
>
>
>--
>Fábio C. Barrionuevo da Luz
>Acadêmico de Sistemas de Informação na Faculdade Católica do Tocantins -
>FACTO Palmas - Tocantins - Brasil - América do Sul
>
>
>--
>You received this message because you are subscribed to the Google Groups
>"Django users" group.
>To unsubscribe from this group and stop receiving emails from it, send an 
>email to
>django-users+unsubscr...@googlegroups.com.
>To post to this group, send email to django-users@googlegroups.com.
>Visit this group at http://groups.google.com/group/django-users.
>To view this discussion on the web visit
>https://groups.google.com/d/msgid/django-users/CAPVjvMYYfW26cqRiU%3Drep
>-pPNe5baq5ZL7b7vU2nK%2BS_A3VR9w%40mail.gmail.com
>p-pPNe5baq5ZL7b7vU2nK%2BS_A3VR9w%40mail.gmail.com?utm_medium=em
>ail_source=footer> .
>For more options, visit https://groups.google.com/d/optout.


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


[OT] Web application and image scanner

2014-05-28 Thread Fabio C. Barrionuevo da Luz
Anyone know any client-side alternative to Java and Java Applets in a Web
application to capture images from Network or USB scanner and send to
server somehow (WebDAV, HTTP POST FILE, or other way)?

-- 
Fábio C. Barrionuevo da Luz
Acadêmico de Sistemas de Informação na Faculdade Católica do Tocantins -
FACTO
Palmas - Tocantins - Brasil - América do Sul

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


Re: Adding models from one app to another app

2014-05-28 Thread Satinderpal Singh
On Wed, May 28, 2014 at 11:01 PM, Inderpreet Singh  wrote:
> This is directory structure of my django site
>  LibreHatti
>|- src
>   |- useraccounts
>   |- librehatti
>  |--- catalog
>  |--- reports
>
> Now what we need is to reference a model from useraccounts in
> librehatti.catalog as a foreign key and I am unable to do that.

You may do it like this models  of librehatti.
from useraccount import model.modelname

If you want all useraccounts model in librehatti, then do like,
from useraccounts.models import *

> I tried by adding 'appname.modelname' in foreign key field but it actually
> refrences librehatti.useraccounts.address, which is not what I want.
>
> Any help would be appreciated.



-- 
Satinderpal Singh
http://satindergoraya91.blogspot.in/

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


Re: hoping for a quick code review of a few simple class-based generic views

2014-05-28 Thread Howard Edson
Thank you - that helps!

On Tuesday, May 27, 2014 3:14:06 PM UTC-7, WongoBongo wrote:
>
> I'd recommend removing the login_required checks from the views. Put them 
> in the UrlConf instead:
>
> from django.contrib.auth.decorators import login_required
>
> from yourapp.views import MyListsView
>
> urlpatterns = patterns('',
> url(r'^$', login_required(MyListsView.as_view()), name='yourapp_list'),
> )
>
> This will allow you to write simpler tests for your views.
>
>
> http://tech.novapost.fr/django-unit-test-your-views-en.html#don-t-decorate-views-in-place
>
> Also, if you restrict your queryset to display only objects for the 
> current user then the generic view will be smart enough to return Http404 
> for requests for object pks that they do not own. Depending on your models, 
> you might need to write a Manager for it.
>
> class ItemDetailView(DetailView):
> model = ItemModel
> template_name = 'cmv_app/item_detail.html'
>
> def get_queryset(self):
> q = self.model.lists.for_user(self.request.user)
> return q
>
> K
>
>
> On Tuesday, May 27, 2014 2:43:03 PM UTC-7, Howard Edson wrote:
>>
>> I am working on a simple "to do list" app in django (two models: List and 
>> Item). Trying to learn and make use of class-based generic views. I have 
>> the following three display views working, but am requesting a quick code 
>> review to see if there's anything I can do to improve my 
>> usage/understanding of django's ListView and DetailView before I move on to 
>> creating, updating and deleting. Thanks in advance for any advice.
>>
>>
>> # class-based generic views for my lists, a list's items, and item 
>> detail...
>> class MyListsView(ListView):
>> """Display the current user's Lists"""
>> template_name = 'cmv_app/my_lists.html'
>> context_object_name = 'my_lists'
>>
>> @method_decorator(login_required)
>> def dispatch(self, *args, **kwargs):
>> return super(MyListsView, self).dispatch(*args, **kwargs)
>>
>> def get_queryset(self):
>> return 
>> List.objects.filter(user=self.request.user).order_by('-last_modified')
>>
>>
>> class ListItemsView(ListView):
>> """Display a list's items"""
>> template_name = 'cmv_app/list_items.html'
>> context_object_name = 'list_items'
>>
>> @method_decorator(login_required)
>> def dispatch(self, request, *args, **kwargs):
>> self.list = get_object_or_404(List, pk=kwargs['list_id'])
>> request = list_valid_for_user(request, self.list) # security check
>> return super(ListItemsView, self).dispatch(request, *args, 
>> **kwargs)
>>
>> def get_queryset(self):
>> return 
>> Item.objects.filter(list=self.list).order_by('-created_date')
>>
>> def get_context_data(self, **kwargs):
>> context = super(ListItemsView, self).get_context_data(**kwargs)
>> context['list'] = self.list
>> return context
>>
>>
>> class ItemDetailView(DetailView):
>> """Display detail for one list item"""
>> template_name = 'cmv_app/item_detail.html'
>>
>> @method_decorator(login_required)
>> def dispatch(self, request, *args, **kwargs):
>> self.list = get_object_or_404(List, pk=kwargs['list_id'])
>> self.item = get_object_or_404(Item, pk=kwargs['item_id'])
>> request = list_valid_for_user(request, self.list)  # security 
>> check
>> request = item_valid_for_list(request, self.item, self.list)  # 
>> security check
>> return super(ItemDetailView, self).dispatch(request, *args, 
>> **kwargs)
>>
>> def get_object(self):
>> return self.item
>>
>> def get_context_data(self, **kwargs):
>> context = super(ItemDetailView, self).get_context_data(**kwargs)
>> context['list'] = self.list
>> return context
>>
>>

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


RE: Adding models from one app to another app

2014-05-28 Thread Ilya Kazakevich
Hello,

The easiest way here is to import model module.

from django.db import model
from some_app.some_package import model as foreign_model

class MyClass(model.Model):
foo = model.ForeignKey(foreign_model.SomeForeignModel)

But you also can import model from any installed app as 
'app_name.model_class_name'.


Ilya Kazakevich,
JetBrains PyCharm (Best Python/Django IDE)
http://www.jetbrains.com/pycharm/
"Develop with pleasure!"


>-Original Message-
>From: django-users@googlegroups.com
>[mailto:django-users@googlegroups.com] On Behalf Of Inderpreet Singh
>Sent: Wednesday, May 28, 2014 9:32 PM
>To: django-users@googlegroups.com
>Subject: Adding models from one app to another app
>
>This is directory structure of my django site
> LibreHatti
>   |- src
>  |- useraccounts
>  |- librehatti
> |--- catalog
> |--- reports
>
>Now what we need is to reference a model from useraccounts in
>librehatti.catalog as a foreign key and I am unable to do that.
>
>I tried by adding 'appname.modelname' in foreign key field but it actually
>refrences librehatti.useraccounts.address, which is not what I want.
>
>Any help would be appreciated.
>
>
>--
>You received this message because you are subscribed to the Google Groups
>"Django users" group.
>To unsubscribe from this group and stop receiving emails from it, send an 
>email to
>django-users+unsubscr...@googlegroups.com.
>To post to this group, send email to django-users@googlegroups.com.
>Visit this group at http://groups.google.com/group/django-users.
>To view this discussion on the web visit
>https://groups.google.com/d/msgid/django-users/dbacf3d8-b4c7-4859-a883-112
>2ab9a9d36%40googlegroups.com
>22ab9a9d36%40googlegroups.com?utm_medium=email_source=footer> .
>For more options, visit https://groups.google.com/d/optout.


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


Adding models from one app to another app

2014-05-28 Thread Inderpreet Singh
This is directory structure of my django site
 LibreHatti
   |- src
  |- useraccounts
  |- librehatti
 |--- catalog
 |--- reports

Now what we need is to reference a model from useraccounts in 
librehatti.catalog as a foreign key and I am unable to do that.

I tried by adding 'appname.modelname' in foreign key field but it actually 
refrences librehatti.useraccounts.address, which is not what I want.

Any help would be appreciated.

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


Re: 1.6.5 as a zip for download?

2014-05-28 Thread carlos
Hi @NeilWalker maybe you need install 7zip http://www.7-zip.org/ in yours
winbug

Cheers


On Wed, May 28, 2014 at 11:09 AM, Neil Walker wrote:

> Thanks, I couldn't figure out how to get a zip from github :)
>
> Might be a good idea to have a zip version at the website alongside the
> tar.gz for simple Window users like me ;)
>
> Neil.
>
>
> On Wednesday, 28 May 2014 17:51:17 UTC+1, Neil Walker wrote:
>>
>> Hello,
>> I wish to download 1.6.5 stable zip without using pip and not as a tar/gz
>> (limitations on software I can use at work), but when I visit the download
>> site and follow the links for manually installing all I get is the latest
>> development build as a zip or 1.6.5 as as tar/z file.
>>
>> Is there a stable release version as a zip available?
>>
>> Thanks.
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/0756d061-b688-4273-a4b9-3bacad6a92be%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: virtualenv help needed

2014-05-28 Thread carlos
Hi, when install virtualenv you need create yours enviroments then you need
install all application you need
example:
$virtualenv django14  #create your enviroments
$source django14/bin/activate  #activate your enviroments
$pip install django==1.4.5  #install all you need application o third party
apps

if need find media of django you
find django14/lib/python2.7/site-packages/django/...

Cheers


On Wed, May 28, 2014 at 10:40 AM, Deepak Sharma wrote:

> A year before I developed an applciation in django==1.4.5 version. Few
> days before I installed virtualenv with django version 1.4.5. In my
> application I have to place "media" folder inside
> /usr/local/lib/[ython2.7/dist-package/django/contrib/admin/media but after
> installating virtualenv I didn't find any django folder inside
> dist-package. Can anyone help me out with this, how should I allocate
> proper path to it?
>
> Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f7e72e87-c1d0-4065-983d-6e1f1b77ccca%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: 1.6.5 as a zip for download?

2014-05-28 Thread Neil Walker
Thanks, I couldn't figure out how to get a zip from github :)

Might be a good idea to have a zip version at the website alongside the 
tar.gz for simple Window users like me ;)

Neil.


On Wednesday, 28 May 2014 17:51:17 UTC+1, Neil Walker wrote:
>
> Hello,
> I wish to download 1.6.5 stable zip without using pip and not as a tar/gz 
> (limitations on software I can use at work), but when I visit the download 
> site and follow the links for manually installing all I get is the latest 
> development build as a zip or 1.6.5 as as tar/z file.
>
> Is there a stable release version as a zip available?
>
> Thanks.
>

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


Re: 1.6.5 as a zip for download?

2014-05-28 Thread Brad Pitcher
Is this what you're looking for?

https://github.com/django/django/archive/1.6.5.zip


On Wed, May 28, 2014 at 9:51 AM, Neil Walker wrote:

> Hello,
> I wish to download 1.6.5 stable zip without using pip and not as a tar/gz
> (limitations on software I can use at work), but when I visit the download
> site and follow the links for manually installing all I get is the latest
> development build as a zip or 1.6.5 as as tar/z file.
>
> Is there a stable release version as a zip available?
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/fa1080dd-ad78-41fa-b00f-6fac7bc431ea%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


virtualenv help needed

2014-05-28 Thread Deepak Sharma
A year before I developed an applciation in django==1.4.5 version. Few days 
before I installed virtualenv with django version 1.4.5. In my application 
I have to place "media" folder inside 
/usr/local/lib/[ython2.7/dist-package/django/contrib/admin/media but after 
installating virtualenv I didn't find any django folder inside 
dist-package. Can anyone help me out with this, how should I allocate 
proper path to it?

Thank you.

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


1.6.5 as a zip for download?

2014-05-28 Thread Neil Walker
Hello,
I wish to download 1.6.5 stable zip without using pip and not as a tar/gz 
(limitations on software I can use at work), but when I visit the download 
site and follow the links for manually installing all I get is the latest 
development build as a zip or 1.6.5 as as tar/z file.

Is there a stable release version as a zip available?

Thanks.

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


Re: How to pass URL to a view

2014-05-28 Thread Vibhu Rishi
Thanks Ilya ! Perfect ! That is what I was missing.

And point noted about reverse.

V.


On Wed, May 28, 2014 at 6:04 PM, Ilya Kazakevich <
ilya.kazakev...@jetbrains.com> wrote:

> Hello,
>
> 1) Never hardcode urls in Django. Use reverse:
> https://docs.djangoproject.com/en/dev/ref/urlresolvers/#django.core.urlresolvers.reverse
> 2) If I understood you correctly, you need to redirect user back. Use
> request header REFERER' (check rfc2616 section 14.36). For Django:
> http://stackoverflow.com/questions/12758786/redirect-return-to-same-previous-page-in-django
> See also: https://docs.djangoproject.com/en/dev/ref/request-response/
>
> Be sure to check this header exists.
>
>
> Ilya Kazakevich,
> JetBrains PyCharm (Best Python/Django IDE)
> http://www.jetbrains.com/pycharm/
> "Develop with pleasure!"
>
>
> >-Original Message-
> >From: django-users@googlegroups.com
> >[mailto:django-users@googlegroups.com] On Behalf Of Vibhu Rishi
> >Sent: Wednesday, May 28, 2014 4:23 PM
> >To: django-users@googlegroups.com
> >Subject: How to pass URL to a view
> >
> >Hi,
> >
> >
> >Maybe there is a better way to achieve what I am trying - so any
> suggestion is
> >welcome :)
> >
> >
> >I have a small view. It does nothing much - if the user clicks a button
> for being
> >interested in something he is looking at - it adds to the table of
> interested things.
> >e.g. as below :
> >
> >@login_required
> >def add_interested_project(request, project_id):
> >project = get_object_or_404(Project, pk=project_id)
> >try:
> >InterestedProject.objects.get(user__pk=request.user.id,
> >project__pk=project.id)
> >except InterestedProject.DoesNotExist:
> >InterestedProject.objects.create(user=request.user,
> project=project)
> >return HttpResponseRedirect("/projects/" + project_id)
> >
> >
> >
> >Now this works fine if he is in the details page e.g. as per the url
> /projects/4 . It
> >works as expected, I am able to add to the table and it redirects back to
> the
> >same page.
> >
> >However, since this is something which I can call from any place, it
> fails in the
> >sense that it gets redirected back to the project details page. E.g. I
> have a listing
> >of projects, on /projects/ , i click the interested button, it
> unfortunately instead of
> >going back to /projects/ goes to /projects/
> >
> >
> >The code in my template file which calls this :
> >
> > class="glyphicon
> >glyphicon-heart"> Interested 
> >
> >
> >The relevant urls.py hookup :
> >url(r'^(?P\d+)/add_interested_project$',
> >views.add_interested_project, name="interestedProjects"),
> >
> >
> >
> >The solution seems apparent that I should just pass the current URL to
> the view
> >so that I can do a redirect back to it - but I am not able to get an
> example of how
> >to actually implement it.
> >
> >
> >Regards,
> >
> >Vibhu
> >
> >
> >--
> >Simplicity is the ultimate sophistication. - Leonardo da Vinci Life is
> really simple,
> >but we insist on making it complicated. - Confucius
> >
> >--
> >You received this message because you are subscribed to the Google Groups
> >"Django users" group.
> >To unsubscribe from this group and stop receiving emails from it, send an
> email to
> >django-users+unsubscr...@googlegroups.com.
> >To post to this group, send email to django-users@googlegroups.com.
> >Visit this group at http://groups.google.com/group/django-users.
> >To view this discussion on the web visit
> >https://groups.google.com/d/msgid/django-users/CAPiONwmgaEG5cCO2LDOh3
> >dJ%2BD8ViYbQvkAk34wBRgD--3e8iQQ%40mail.gmail.com
> > >3dJ%2BD8ViYbQvkAk34wBRgD--3e8iQQ%40mail.gmail.com?utm_medium=emai
> >l_source=footer> .
> >For more options, visit https://groups.google.com/d/optout.
> >
> >
> >No virus found in this message.
> >Checked by AVG - www.avg.com
> >Version: 2014.0.4592 / Virus Database: 3950/7573 - Release Date: 05/27/14
> >
> >
> >
> >No virus found in this message.
> >Checked by AVG - www.avg.com
> >Version: 2014.0.4592 / Virus Database: 3950/7563 - Release Date: 05/26/14
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/008e01cf7a71%241d85e100%245891a300%24%40JetBrains.com
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Simplicity is the ultimate sophistication. - Leonardo da Vinci
Life is really simple, but we insist on making it complicated. - Confucius

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this 

Re: Mysql DB local socket access errors with mod_wsgi

2014-05-28 Thread jirka . vejrazka
It's very likely a permissions problem. Webserver processes tend to run under a 
special username (e.g. www-data) with very limited permissions - it's likely 
that this user does not have access to the socket file.

  HTH

   Jirka

-Original Message-
From: Henning Sprang 
Sender: django-users@googlegroups.com
Date: Wed, 28 May 2014 11:28:00 
To: 
Reply-To: django-users@googlegroups.com
Subject: Mysql DB local socket access errors with mod_wsgi

Hi,

I'm trying to setup a django production environment with mod_wsgi, and
a local mysql  which I want to connect via the socket file.

Without wsgi the app runs and connects to the database.

When running it via wsgi, I get:

OperationalError

(2002, "Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (13)")

It might be relevant that I'm running the app and the db in Docker
containers, sharing the directory with the socket file in between
them. On the other hand, as running the app manually with runserver
works well, I guess it must be something else.

I tried every imaginable configuration, from the simplest described in
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/modwsgi/
to just about anything described there, the socket file defintely
exists at this path, and I also tried to explicitly allow apache
access with a directory/files directive in apache - no success.

Any ideas?

-- 
Henning Sprang
http://www.sprang.de

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB10%2BLu%3DJwCgLv46FDpE3-4Tu6b%2B7C15rf1vcEBsmFXB%2B44NCA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2097542386-1401286725-cardhu_decombobulator_blackberry.rim.net-540712219-%40b1.c3.bise7.blackberry.
For more options, visit https://groups.google.com/d/optout.


Help - Django App on Heroku & local dev machine

2014-05-28 Thread Dr Shauny
Hi,

I have a Django app already deployed and fully functional on Heroku. The 
app was purchased from a third party that transferred the codebase via 
github.

I need to make changes and redeploy the app but understand that this is not 
possible (or advisable) directly from github itself.

I therefore need to set up a local development environment for the app from 
where I can deploy changes to the github repository and also deploy updates 
to the installation on Heroku.

Heroku have an article that explains how to create a new app and upload 
this to Heroku ("Getting started with Django on Heroku") , however many of 
the details appear to be for a new app rather than for my situation where I 
already have a fully functional app. I am unsure as to what I should and 
shouldnt do as I am unclear about the relevancy of some of the instructions.

Can anyone walk me through the process of transferring an app from github 
to a local machine so that I can dev on the local machine. OS would be 
ubuntu 12.04 and ideally want to set up dev and prod repos on github (and 
eventually dev and prod apps on heroku). I believe I have done most of the 
local work with postgres, python virtualenv, heroku and django toolbelts 
etc, but would really appreciate an expert to bounce some queries off?

Anyone able to help?

S.

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


Re: How to use CreateView with crispy-forms

2014-05-28 Thread Andromeda Yelton
The | crispy filter provides only minimal (though stylish) rendering - if
you want to render all the cool stuff in your helper you need to do {%
crispy form %}.

Andromeda Yelton
LITA Board of Directors, Director-at-Large, 2013-2016
http://andromedayelton.com
@ThatAndromeda


On Wed, May 28, 2014 at 8:43 AM, <9devm...@gmail.com> wrote:

> I want to use CreateView along with crispy-forms generated layout.
> However, it seems that everything I pass to *self.helper* in *forms.py*is 
> ignored. Form renders nicely, but only with fields generated by
> CreateView - all fields passed to *Layout* are missing.
>
> My views.py
>
>> class MyView(CreateView):
>> form_class = MyForm
>> model = MyModel
>>
>> def form_valid(self, form):
>> pass
>>
>> My forms.py:
>
>> from django.forms import ModelForm, Textareafrom crispy_forms.helper import 
>> FormHelperfrom crispy_forms.layout import Submit, Layoutfrom 
>> crispy_forms.bootstrap import FormActions
>> from .models import MyModel
>> class MyForm(ModelForm):
>>
>> def __init__(self, *args, **kwargs):
>> super(MyForm, self).__init__(*args, **kwargs)
>> self.helper = FormHelper(self)
>> self.helper.form_method = 'POST'
>> self.helper.add_input(Submit('submit', 'Submit'))
>> self.helper.layout = Layout(
>> FormActions(Submit('BlahBlah', 'BlahBlah', 
>> css_class='btn-primary')))
>>
>> class Meta:
>> model = MyModel
>> fields = ['xxx', 'yyy']
>>
>> My image_form.html:
>
>> {% load crispy_forms_tags %}...> enctype="multipart/form-data">
>> {% csrf_token %}
>> {{ form|crispy }}
>>
>> What else should I do to make it work?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2555778c-3f3f-43b4-8670-80ea8abdd1ba%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Custom user model backend

2014-05-28 Thread Domagoj Kovač
Hi guys,

I extended base user model with certain fields. My code is as follows:

#!/usr/bin/env python
> # -*- coding: utf-8 -*-
> from django.utils import timezone
> from django.conf import settings
> from django.contrib.auth.backends import ModelBackend
> from django.core.exceptions import ImproperlyConfigured
> from django.db.models import get_model

 

 

class CustomUserModelBackend(ModelBackend):
> def authenticate(self, username=None, password=None):
> try:
> user = self.user_class.objects.get(username=username)
> if user.login_duration is None or user.login_duration >= 
> timezone.now():
> if user.check_password(password):
> return user
> else:
> return None
> except self.user_class.DoesNotExist:
> return None


> def get_user(self, user_id):
> try:
> return self.user_class.objects.get(pk=user_id)
> except self.user_class.DoesNotExist:
> return None
> @property
> def user_class(self):
> if not hasattr(self, '_user_class'):
> self._user_class = 
> get_model(*settings.CUSTOM_USER_MODEL.split('.', 2))
> if not self._user_class:
> raise ImproperlyConfigured('Could not get custom user 
> model')
> return self._user_class


Everything works as it should but if i am logged in system logs me out 
after certain time even i am using application. Is there something i missed 
that controls how login persistence is handled?

Best,
Domagoj 

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


How to use CreateView with crispy-forms

2014-05-28 Thread 9devmail
 

I want to use CreateView along with crispy-forms generated layout. However, 
it seems that everything I pass to *self.helper* in *forms.py* is ignored. 
Form renders nicely, but only with fields generated by CreateView - all 
fields passed to *Layout* are missing.

My views.py

> class MyView(CreateView):
> form_class = MyForm
> model = MyModel
>
> def form_valid(self, form):
> pass
>
> My forms.py:

> from django.forms import ModelForm, Textareafrom crispy_forms.helper import 
> FormHelperfrom crispy_forms.layout import Submit, Layoutfrom 
> crispy_forms.bootstrap import FormActions
> from .models import MyModel
> class MyForm(ModelForm): 
>
> def __init__(self, *args, **kwargs):
> super(MyForm, self).__init__(*args, **kwargs)
> self.helper = FormHelper(self)
> self.helper.form_method = 'POST'
> self.helper.add_input(Submit('submit', 'Submit'))
> self.helper.layout = Layout( 
> FormActions(Submit('BlahBlah', 'BlahBlah', 
> css_class='btn-primary')))
>
> class Meta:
> model = MyModel
> fields = ['xxx', 'yyy']
>
> My image_form.html:

> {% load crispy_forms_tags %}... enctype="multipart/form-data">
> {% csrf_token %}
> {{ form|crispy }}
>
> What else should I do to make it work?

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


Re: Model field's verbose_name from database?

2014-05-28 Thread Степан Дибров
from django.utils.functional import lazy

def field_verbose_db(field_name):
from app.models import FieldNamesMap
return FieldNamesMap.objects.get(key=field_name).title

field_verbose_db_lazy = lazy(field_name, unicode)

first_name = models.CharField(..., 
verbose_name=field_verbose_db_lazy('first_name')) 

вторник, 4 февраля 2014 г., 22:03:08 UTC+4 пользователь Jon Dufresne 
написал:
>
> Hi, 
>
> I have a model with fields that allows the user to modify the 
> user-facing names of these fields. Think "first name", "last name", 
> "email", the user may prefer these be displayed as "given name", 
> "surname", "email address". This is configured exactly once throughout 
> the system. So in this example *all* instances of "first name" should 
> instead be displayed as "given name". Is it possible have a model 
> where "verbose_name" is not a static string, but instead comes from 
> the database? Perhaps with some lazy loading trickery? I want to do 
> something in the spirit of: 
>
> first_name = models.CharField(..., verbose_name=lazy_load_name_from_db()) 
>
> My hope is to eliminate the need to think about what to call this 
> field when displayed to the user. 
>
> Thanks, 
> Jon 
>

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


Re: OneToOne? Inheritance? Another solution for nested model relationships?

2014-05-28 Thread Daniele Procida
On Wed, May 28, 2014, Leonardo Giordani  wrote:

>I usually solve such issues with Inheritance. I feel comfortable with it
>because it lets me (in your example) to manage both ResearchStudent and
>ResearchStaff independently, while keeping the Researcher parent model
>available to deal with "global" queries and data interaction.

It it were a case where abstract inheritance would work, I would agree. 
Unfortunately, the Researcher model can't be abstract (because it has its own 
relations with Publications).

If I use multi-table inheritance, that solves part of the problem. However I 
don't know how well it would work if I have a Researcher, who at some point 
needs to be a ResearchStudent and maybe later becomes ResearchStaff.

Regards,

Daniele

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


RE: How to pass URL to a view

2014-05-28 Thread Ilya Kazakevich
Hello,

1) Never hardcode urls in Django. Use reverse: 
https://docs.djangoproject.com/en/dev/ref/urlresolvers/#django.core.urlresolvers.reverse
2) If I understood you correctly, you need to redirect user back. Use request 
header REFERER' (check rfc2616 section 14.36). For Django: 
http://stackoverflow.com/questions/12758786/redirect-return-to-same-previous-page-in-django
See also: https://docs.djangoproject.com/en/dev/ref/request-response/

Be sure to check this header exists.


Ilya Kazakevich,
JetBrains PyCharm (Best Python/Django IDE)
http://www.jetbrains.com/pycharm/
"Develop with pleasure!"


>-Original Message-
>From: django-users@googlegroups.com
>[mailto:django-users@googlegroups.com] On Behalf Of Vibhu Rishi
>Sent: Wednesday, May 28, 2014 4:23 PM
>To: django-users@googlegroups.com
>Subject: How to pass URL to a view
>
>Hi,
>
>
>Maybe there is a better way to achieve what I am trying - so any suggestion is
>welcome :)
>
>
>I have a small view. It does nothing much - if the user clicks a button for 
>being
>interested in something he is looking at - it adds to the table of interested 
>things.
>e.g. as below :
>
>@login_required
>def add_interested_project(request, project_id):
>project = get_object_or_404(Project, pk=project_id)
>try:
>InterestedProject.objects.get(user__pk=request.user.id,
>project__pk=project.id)
>except InterestedProject.DoesNotExist:
>InterestedProject.objects.create(user=request.user, project=project)
>return HttpResponseRedirect("/projects/" + project_id)
>
>
>
>Now this works fine if he is in the details page e.g. as per the url 
>/projects/4 . It
>works as expected, I am able to add to the table and it redirects back to the
>same page.
>
>However, since this is something which I can call from any place, it fails in 
>the
>sense that it gets redirected back to the project details page. E.g. I have a 
>listing
>of projects, on /projects/ , i click the interested button, it unfortunately 
>instead of
>going back to /projects/ goes to /projects/
>
>
>The code in my template file which calls this :
>
> Interested 
>
>
>The relevant urls.py hookup :
>url(r'^(?P\d+)/add_interested_project$',
>views.add_interested_project, name="interestedProjects"),
>
>
>
>The solution seems apparent that I should just pass the current URL to the view
>so that I can do a redirect back to it - but I am not able to get an example 
>of how
>to actually implement it.
>
>
>Regards,
>
>Vibhu
>
>
>--
>Simplicity is the ultimate sophistication. - Leonardo da Vinci Life is really 
>simple,
>but we insist on making it complicated. - Confucius
>
>--
>You received this message because you are subscribed to the Google Groups
>"Django users" group.
>To unsubscribe from this group and stop receiving emails from it, send an 
>email to
>django-users+unsubscr...@googlegroups.com.
>To post to this group, send email to django-users@googlegroups.com.
>Visit this group at http://groups.google.com/group/django-users.
>To view this discussion on the web visit
>https://groups.google.com/d/msgid/django-users/CAPiONwmgaEG5cCO2LDOh3
>dJ%2BD8ViYbQvkAk34wBRgD--3e8iQQ%40mail.gmail.com
>3dJ%2BD8ViYbQvkAk34wBRgD--3e8iQQ%40mail.gmail.com?utm_medium=emai
>l_source=footer> .
>For more options, visit https://groups.google.com/d/optout.
>
>
>No virus found in this message.
>Checked by AVG - www.avg.com
>Version: 2014.0.4592 / Virus Database: 3950/7573 - Release Date: 05/27/14
>
>
>
>No virus found in this message.
>Checked by AVG - www.avg.com
>Version: 2014.0.4592 / Virus Database: 3950/7563 - Release Date: 05/26/14


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


How to pass URL to a view

2014-05-28 Thread Vibhu Rishi
Hi,

Maybe there is a better way to achieve what I am trying - so any suggestion
is welcome :)

I have a small view. It does nothing much - if the user clicks a button for
being interested in something he is looking at - it adds to the table of
interested things. e.g. as below :

@login_required
def add_interested_project(request, project_id):
project = get_object_or_404(Project, pk=project_id)
try:
InterestedProject.objects.get(user__pk=request.user.id, project__pk=
project.id)
except InterestedProject.DoesNotExist:
InterestedProject.objects.create(user=request.user, project=project)
return HttpResponseRedirect("/projects/" + project_id)


Now this works fine if he is in the details page e.g. as per the url
/projects/4 . It works as expected, I am able to add to the table and it
redirects back to the same page.

However, since this is something which I can call from any place, it fails
in the sense that it gets redirected back to the project details page. E.g.
I have a listing of projects, on /projects/ , i click the interested
button, it unfortunately instead of going back to /projects/ goes to
/projects/

The code in my template file which calls this :

 Interested 

The relevant urls.py hookup :
url(r'^(?P\d+)/add_interested_project$',
views.add_interested_project, name="interestedProjects"),


The solution seems apparent that I should just pass the current URL to the
view so that I can do a redirect back to it - but I am not able to get an
example of how to actually implement it.

Regards,
Vibhu

-- 
Simplicity is the ultimate sophistication. - Leonardo da Vinci
Life is really simple, but we insist on making it complicated. - Confucius

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


Mysql DB local socket access errors with mod_wsgi

2014-05-28 Thread Henning Sprang
Hi,

I'm trying to setup a django production environment with mod_wsgi, and
a local mysql  which I want to connect via the socket file.

Without wsgi the app runs and connects to the database.

When running it via wsgi, I get:

OperationalError

(2002, "Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (13)")

It might be relevant that I'm running the app and the db in Docker
containers, sharing the directory with the socket file in between
them. On the other hand, as running the app manually with runserver
works well, I guess it must be something else.

I tried every imaginable configuration, from the simplest described in
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/modwsgi/
to just about anything described there, the socket file defintely
exists at this path, and I also tried to explicitly allow apache
access with a directory/files directive in apache - no success.

Any ideas?

-- 
Henning Sprang
http://www.sprang.de

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB10%2BLu%3DJwCgLv46FDpE3-4Tu6b%2B7C15rf1vcEBsmFXB%2B44NCA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Data + admin design problem

2014-05-28 Thread Derek
Hi

Off the top of my head (as in "do not use directly"!), it seems to me that:

1. You need a boolean field for 'serial' and also one for 'countable' for a 
Product.  One or both must be checked (use clean() to check) when Product 
is created.
2. Each Product also needs a 'status' field:  one of 'available', 'on loan' 
(and, perhaps, 'missing' or 'reserved')
3. I assume that an "Event" is an instance of a Product being lent out 
(that was not clear) with a one:Many to Products.  Each Event can then pull 
in Products as needed (but only from those that are 'available').  You 
could also have "planned" events that can "reserve" items.  A post-trigger 
on the Event save() can update the "status" field of each item and also 
make an entry to the ProductHistory (but its not clear at what point in the 
process a user would add comments??)
4.  Not sure why a Product cannot be effectively linked to a Warehouse via 
FK?  This should work as a Product cannot be in two places at the same time!
5. To move Products between Warehouses, I would use an action, with an 
intermediate page, in the Admin - see 
https://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/ and 
http://www.jpichon.net/blog/2010/08/django-admin-actions-and-intermediate-pages/
 
and https://gist.github.com/rturowicz/5472482

Your comment about "List of items (change_list in admin) shouldn't have 5 
items of serial+countable, just one" does not make sense. To do the 
one:many for an Event, you'd need to add Products, each of which should 
have its own serial number and status (i.e. serial number and status are 
NOT detached from a Product but part of the model.)

To be honest, you do not give enough details about the actual data, and 
user requirements, associated with every item (Product, Warehouse, Event) 
to really understand your scenario and create the best logic.

HTH though.


On Tuesday, 27 May 2014 01:43:29 UTC+2, Wojtas wrote:
>
> Hi there!
> I didn't know where to ask. I'm doing Django for couple of years, and I 
> encountered following problem.
>
> I'm doing a website which manages warehouse of company which lends music 
> instruments.
>
> I have 3 types of products:
> serial -> which exist only in amount of 1
> countable -> which exist in many amounts, like for example jack cable - 
> they don't need information which one is broken for instance, so just 
> information how many can we take
> *serial+countable* -> normally it doesn't matter which is which, in case 
> sth is lost or broken.
>
> I'm using of course django admin to manage the data. 
>
> Let's call the  warehouse product Stuff
> It's not a big problem to save the data and manage it, but I have some 
> specific requirements for serial+countable:
> 1. Reserve stuff for period of time. All 3 types in specific amount ( if 
> available at this time)
> 2. Move specific amount of items from one warehouse to another (for 
> instance one serial+countable object gets broken and we need to move them 
> to repair warehouse from main)
> 3. every serial+countable object should have own history of events + 
> comment history attached to it)
> 4. List of items (change_list in admin) shouldn't have 5 items of 
> serial+countable, just one, with listing of serial numbers and status of 
> each one of them inside the edit view.
>
>
> What I achieved so far:
> I have models:
> Stuff
> Event with M2M to Stuff which is through intermediate table with extra 
> count field. So I can check for two basic types of stuff how many are busy 
> at this time.
>
> So far there is no any definition of serial+countable in the models except 
> for char choice field.
>
> So there's a FK from Stuff to Warehouse model, which is not enough.
>
> I hope my problem description is complete. 
>
> Thank you for any help.
>

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


Re: ASP .NET web service and Django

2014-05-28 Thread shar100101
Thanks everyone. I will try using suds but if suds use C libs, like soaplib 
does (lxml ), than this wont work too.

@Vernon

I don't know for IronPython3. I didn't managed to set up Django 1.5, there 
was errors in Django six.py lib ("""Utilities for writing code that runs on 
Python 2 and 3""") exec_ function. There was problems with  -X:Frames and 
namespaces so I gave up on this.

I use this 'hacks':

IronPython 2.7.3
Django 1.4
IIS 7.5
.NET Framewok 4.0
NWSGI [http://nwsgi.codeplex.com]

I
* AttributeError: 'module' object has no attribute '_getframe'
Use startproject  and startproject with -X:Frames

II
*
STATIC_URL = 'static/' # not  '/static/'

III
To use nice Django URL, use wildcard mapping

 

   


   
  
 

  

While using wildcard mappings you will have some limitations in urls.py 
with regular expressions.
If you use named groups in mapping whole expression is got to be in the 
named group.
 And every expression is got to start with ^ and end with $.
e.g.
url(r'^(?Pnotify).*$', 'helloworld.views.reset_cache'), - this 
wan't work
url(r'^(?Pnotify)(?P.*)$', 
'helloworld.views.reset_cache'), - this will work

IV
If you get something like this error wen loading images:
"Unable to translate bytes [FF] at index 0 from specified code page to 
Unicode."

then in Django static.py change
C:\Program Files (x86)\IronPython 
2.7\Lib\site-packages\django\views\static.py
63 "response = HttpResponse(f.read(), mimetype=mimetype)" with
63 "response = HttpResponse(bytes(f.read()), mimetype=mimetype)"

V
If you use non-ascii caracters. 
* 'Unicode Decode Error:' then change:
C:\Program Files (x86)\IronPython 
2.7\Lib\site-packages\django\http\__init__.py
717 def next(self):
chunk = self._iterator.next()
if isinstance(chunk, unicode):
chunk = chunk.encode(self._charset)
return str(chunk)
to:  
def next(self):
chunk = self._iterator.next()
if isinstance(chunk, unicode):
chunk = chunk.encode('utf8').encode('utf8')
return str(chunk, 'utf8')

VI
To use filebased cache, remove pickle.HIGEST_PROTOCOL in 
C:\Program Files (x86)\IronPython 
2.7\Lib\site-packages\django\core\cache\backends\filebased.py
try:  
now = time.time()   
pickle.dump(now + timeout, f, pickle.HIGHEST_PROTOCOL)
pickle.dump(value, f, pickle.HIGHEST_PROTOCOL)
finally:

try:  
now = time.time()   
pickle.dump(now + timeout, f)
pickle.dump(value, f)
finally:

VII
I do not use database. In order to create sqlite3 db use python

VIII
django/utils/functional.py

django 1.4:

#assert not (cls._delegate_str and cls._delegate_unicode), "Cannot call 
lazy() with both str and unicode return types."
assert (str is unicode) or not (cls._delegate_str and 
cls._delegate_unicode), "Cannot call lazy() with both str and unicode 
return types."
# This solve: 
# AssertionError: Cannot call lazy() with both str and unicode return 
types.
# https://bitbucket.org/jdhardy/django-ironpython/commits/b70eeacda60c




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


Re: Django get queryset year month day

2014-05-28 Thread Leonardo Giordani
If I correctly understand you issue is to get part of the date for each
item in a list of datetime.datetime or datetime.date objects.
To do this you can process the list after the query

new_list = [item.year for item in item]

But if your need is to extract fields from the objects in the result list
you may use 
values()or
values_list()
.

Let me know if this answers your question.

Regards,

Leo



Leonardo Giordani
Author of The Digital Cat 
My profile on About.me  - My GitHub
page- My Coderwall
profile 


2014-05-27 12:40 GMT+02:00 Helton Alves :

> Hi guy.
> so, A don't is understand very well.
>
> but the django has the generic date views, I think is exactly this.
>
>
> https://docs.djangoproject.com/en/dev/ref/class-based-views/generic-date-based/#module-django.views.generic.dates
>
>
>
>
> 2014-05-27 9:06 GMT+01:00 hito koto :
>
> Hi,
>>
>> I want to get only year and get only month,
>> i want to get the only : 2005  and  05-27
>> How can i to do?
>>
>> I know this :
>>
>> >>> Entry.objects.dates('pub_date', 'year')[datetime.date(2005, 1, 1)]>>> 
>> >>> Entry.objects.dates('pub_date', 'month')[datetime.date(2005, 2, 1), 
>> >>> datetime.date(2005, 3, 1)]>>> Entry.objects.dates('pub_date', 
>> >>> 'day')[datetime.date(2005, 2, 20), datetime.date(2005, 3, 20)]>>> 
>> >>> Entry.objects.dates('pub_date', 'day', order='DESC')[datetime.date(2005, 
>> >>> 3, 20), datetime.date(2005, 2, 20)]>>> 
>> >>> Entry.objects.filter(headline__contains='Lennon').dates('pub_date', 
>> >>> 'day')[datetime.date(2005, 3, 20)]
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/f6351f85-5dbf-47f3-a475-122fb52e6fa2%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
>
> Helton Alves 
> Desenvolvedor web
> Graduado em Sistemas de Informação - FACIMP
> Cursando Metodologia do Ensino Superior - INESPO
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CABcoSmBznZKLD9uWa3nkW0-Tw6QPT7GJ8tTyS6FFYLUx-6U1Qw%40mail.gmail.com
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: OneToOne? Inheritance? Another solution for nested model relationships?

2014-05-28 Thread Leonardo Giordani
Daniele,

I usually solve such issues with Inheritance. I feel comfortable with it
because it lets me (in your example) to manage both ResearchStudent and
ResearchStaff independently, while keeping the Researcher parent model
available to deal with "global" queries and data interaction.

As always with inheritance, I suggest to think twice before implementing
it, but in this case I'd say that it fits perfectly.


Regards,

Leo

Leonardo Giordani
Author of The Digital Cat 
My profile on About.me  - My GitHub
page- My Coderwall
profile 


2014-05-26 23:33 GMT+02:00 Daniele Procida :

> I've an application that's been happily running for a few years, that does
> this:
>
> class Person(Model):
># everyone's a Person
>
> class Researcher(Model):
> # a Researcher is Person who publishes research
> person = models.OneToOneField(Person)
>
> class Publication(Model):
> author = models.ForeignKey(Researcher)
>
>
> But this is no longer enough: now I also need to distinguish between
> Researchers who are research students and members of staff. Those who are
> students will need new fields such as "thesis_title" and "supervisors".
>
> But, I will *still* need the Researcher class independently of the new
> ResearchStudent and ResearchStaff classes, because it's needed for
> Publication.author.
>
> So now it might look something like this:
>
> class Person(Model):
># everyone's a Person
>
> class Researcher(Model):
> # a Researcher is Person who publishes research
> person = models.OneToOneField(Person)
>
> class ResearchStaff(Model):
>researcher = models.OneToOneField(Researcher)
>
> class ResearchStudent(Model):
>researcher = models.OneToOneField(Researcher)
>supervisors = models.ManyToManyField(ResearchStaff)
>
> class Publication(Model):
> author = models.ForeignKey(Researcher)
>
>
> How manageable is this going to be? Is there a better way of doing what I
> need to do, perhaps through inheritance?
>
> Thanks,
>
> Daniele
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/20140526213320.1042853662%40mail.wservices.ch
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Formsets, adding new forms and autocomplete/ajax selects

2014-05-28 Thread Sanjay Bhangar
hey Lachlan,

So this had driven me a bit crazy some years ago ..

On Wed, May 28, 2014 at 8:42 AM, Lachlan Musicman  wrote:
> Hola,
>
> I am trying to get two different "extras" to work.
>
> I have a form with an inline_formset, which I would like to be able to
> add multiple formsets of on the fly.
>
> Each of those formsets has another FK to a model with a very large
> dataset, so I would also like to implement some sort of
> autocomplete/ajax/select2/typeahead solution to prevent an unusably
> large select
>

I had two additional extras :):

i> The FK could also be an m2m that should be handled by select2.

ii> There should also be an Add + button next to the select2 to add a
new instance, which opens up a pop-up to add a new item, like it does
in the Django admin.

And then I needed this on a whole bunch of models / forms, so I needed
it abstracted / generalized in some way. Unfortunately, the solution I
came up with involves some ugly hacks, so I'm slightly embarassed by
it, haha - its also for a much older version of Django, etc. (1.3,
iirc).

However, I still think this is a really kick-ass and useful thing to
be able to do simply - I'd be happy to try and catch up with you
off-list (which we've been meaning to do anyways, ha!) and see if we
can have some fun rolling a little django app for this or so.

> Here is my basic set up.
>
> models.py
> 
> class PartNumber(models.Model):
> name = models.CharField("Description", max_length=100)
> supplier_part_number = models.CharField(max_length=30,
> unique=True, blank=True, null=True)
>
> class PurchaseOrder(models.Model):
> po_number = models.CharField('PO number', max_length=10, unique=True)
> ordered_date = models.DateField(default=today)
>
> class PurchaseOrderPart(models.Model):
> part_number = models.ForeignKey(PartNumber, related_name='purchases')
> po_number = models.ForeignKey(PurchaseOrder, related_name='partslist')
> delivery_date = models.DateField(null=True, blank=True)
> qty_ordered = models.IntegerField('Quantity
> ordered',validators=[MinValueValidator(1)])
> cost = models.DecimalField('Unit Cost',
> max_digits=10,decimal_places=2,blank=True,null=True)
>
>
> forms.py
> -
>
> class PurchaseOrderPartForm(forms.ModelForm):
> class Meta:
>   fields = ('part_numbers', 'delivery_date', 'qty_ordered', 'cost')
>   model = PurchaseOrderPart
>   widgets={
> 'part_numbers': forms.Select(attrs={'class':'form-control'}),
> 'delivery_date': CalendarWidget(attrs={'class':'input-append
> form-control'}),
> 'qty_ordered': forms.NumberInput(attrs={'class':'form-control'}),
> 'cost': forms.NumberInput(attrs={'class':'form-control'}),
> }
>
> POPartFormset = inlineformset_factory(PurchaseOrder,
> PurchaseOrderPart, form=PurchaseOrderPartForm, extra=1,
> can_delete=True)
>
>
> I have successfully implemented jquery.formset.js (
> https://github.com/elo80ka/django-dynamic-formset ) to create "add"
> and "remove" buttons - this allows for a variable number of
> PurchaseOrderParts on a PurchaseOrder.
>
>
> When I then implemented django-select2 I was mostly successful, except
> for one problem - the way that django-select2 implements field is by
> adding some js on render.
>
> Since the jquery.formset.js was creating forms on the fly, any
> formsets added via it's add button did not have the required
> django-select2 container, and hence had no widget at all.
>
> jquery.formset.js has an "added" function that allows for something
> like this, but then I would need to glue it all together and it
> doesn't seem clean enough.
>

So, I used a similar approach - jquery.formset.js and select2. What I
did was I created a little jquery plugin / wrapper around select2 to
be able to instantiate it with a simple call to like
$('#select_field_id_foo').mySelect2();. I then also created a custom
widget for the autocompletes, which would ensure their custom options
were in the html to be read by the plugin.

So, this is the custom widget class I made:
http://code.camputer.org/itf/annotate/head%3A/itf/app/forms.py#L42

This is its template:
http://code.camputer.org/itf/annotate/head%3A/itf/templates/formwidgets/select2.html

Then I can simply instantiate the widget in my form definition like so:

group = forms.ModelChoiceField(TheatreGroup.objects.all(),
widget=AutocompleteAddWidget(model_class=TheatreGroup))
See for eg: 
http://code.camputer.org/itf/annotate/head%3A/itf/itfprofiles/forms.py#L129

So far so good. Where the ugly hackery lies is the javascript - as you
mention, to work around the problem of instantiating when adding a new
formset and other problems when using the Django Admin JS for the
pop-up forms, I landed up hacking in the jquery.formset.js code
itself, which I'm not proud of. I think this can probably be
accomplished cleaner using the 'added' callback or so, as you mention
(and make your single point of entry / 

Django-stripe-payments example project

2014-05-28 Thread yakkadesign
 

Does anyone know of an example project with django-stripe-payments? All the 
documentation and tutorials I've found stops after configuring the admin 
backend. I'm not sure how to setup the forms so that the end user can pay 
and manage their subscription. 


 I want to use stripe. I'm open to other django apps. 


 Brian

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