Re: Understanding users auth in Django

2013-04-14 Thread Nora Olsen


On Monday, April 15, 2013 8:46:37 AM UTC+8, Russell Keith-Magee wrote:
>
>
>> Should I be using the Admin Site? But the organization admin is really 
>> not a super user/staff member of the app. 
>>
>
> This question is orthogonal to your other questions. Django's Admin site 
> isn't intended as a general purpose, user-facing administration console for 
> your site. It's intended for internal site administration use only. 
>
> If you're making a distinction between your own site administrators, and 
> an "administrator" role amongst a particular group of users/organization, 
> then you'll almost certainly have a separate administration interface for 
> those users -- but that doesn't preclude you from using Django's Admin for 
> your own internal administration.
>

Yup, I am inclining to have a separate administration interface for the 
administrator role , and not site administrator.

I have looked at AdminSite and ModelAdmin. Should I be using them? 

Do people typically run with admin site in production?

>

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




Django-Registration/Custom Authentication Issue

2013-04-14 Thread Lee Hinde
I'm trying to do a 'simple' registration with just a user email and
password required to create an account. I'm using django-registration with
django 1.5.1 and have created a custom model and the custom model manager.

I can hit all the registration forms just fine and have copied the example
from the django docs (ignoring, temporarily, the admonition not to do
that.).

I've created a custom backend in django-registration, basically to remove
the username requirement. In fact, my custom backend is identical to the
default, minus any references to the username.

When I try to create a new user (i.e, submit the form), from
/accounts/register/ I get the following error:

AttributeError at /accounts/register/
Manager isn't available; User has been swapped for 'letters.PCSUser'

The full trace back is:

File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in
get_response
  115. response = callback(request, *callback_args,
**callback_kwargs)
File "/Library/Python/2.7/site-packages/django/views/generic/base.py" in
view
  68. return self.dispatch(request, *args, **kwargs)
File
"/Users/leehinde/Documents/Clients/ProfessionalCreditSolutions/pcs/pcs/registration/views.py"
in dispatch
  79. return super(RegistrationView, self).dispatch(request, *args,
**kwargs)
File "/Library/Python/2.7/site-packages/django/views/generic/base.py" in
dispatch
  86. return handler(request, *args, **kwargs)
File
"/Users/leehinde/Documents/Clients/ProfessionalCreditSolutions/pcs/pcs/registration/views.py"
in post
  35. return self.form_valid(request, form)
File
"/Users/leehinde/Documents/Clients/ProfessionalCreditSolutions/pcs/pcs/registration/views.py"
in form_valid
  82. new_user = self.register(request, **form.cleaned_data)
File
"/Users/leehinde/Documents/Clients/ProfessionalCreditSolutions/pcs/pcs/registration/backends/pcs/views.py"
in register
  80.
password, site)
File "/Library/Python/2.7/site-packages/django/db/transaction.py" in inner
  223. return func(*args, **kwargs)
File
"/Users/leehinde/Documents/Clients/ProfessionalCreditSolutions/pcs/pcs/registration/models.py"
in create_inactive_user
  78. new_user = User.objects.create_user( email, password)
File "/Library/Python/2.7/site-packages/django/db/models/manager.py" in
__get__
  256. self.model._meta.object_name, self.model._meta.swapped


No doubt I've left out some needed component to show why this error is
coming up, but I'm not sure what.  I'm grateful for any pointers on where I
should be looking.

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




Re: Understanding users auth in Django

2013-04-14 Thread Venkatraman S
I've done something similar for my own personal project and i can share how
i did it:

I used the Django User.
And then created a ProfileDetails model that has a OneToOneField with User.
An Organization Model
An Employee Model - Contains FK to Organization and User

Also, i did implemented my own permission scheme wherein the Admin of an
Org can setup permissions for the Org. For eg. whether an Item can be
shared amongst user or each user can only view what they have created etc,
So, every time an Item has accessed i check the Org setting for this
'sharing' permission and then return.


if SHARED_WORKSPACE == 1:
  items =
Items.objects.filter(created_by__employees__org__in=self.employees_set.all().values_list('org')).filter(status="AVAILABLE")
else:
  items = Item.objects.filter(created_by=self)

I am in the process of finetuning this method and make things more robust,
for if i want to check the access level on an Item for a particular logged
in Employee, i have to first get the Org, and then the Org Level Permission
setting(which obviously can be cached) and then check the Item.

Venkat

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




Re: Understanding users auth in Django

2013-04-14 Thread Russell Keith-Magee
On Mon, Apr 15, 2013 at 12:44 AM, Nora Olsen  wrote:

> Hi,
>
> I'm using Django 1.5 and I have looked at guardian / Userena / pinax user
> accounts but I'm not sure how they work with the authentication mechanism
> in Django.
>
> I'm creating a site that typically have the following the groups :
> 1. Super Admin: Myself
> 2. Organization admin. This is created by super admin only.
> 3. Organization user group: A, B, C, such as editors, moderators, finance,
> hr, etc
>
> These user groups have the same role regardless of the organization.
>
> This is similar to most site, such as mailchimp/mixpanel/aws/etc, that the
> first account is an admin account. Using that admin account, the user will
> be able to create other accounts and assign roles to them. Roles come with
> fix set of permissions across the entire site.
>
> I'm trying to create a typical site with a login page with email &
> password. Upon login, the organization admin would be able to access the
> "Organization accounts" under his/her dashboard to manage their users.
>
> If it's a normal user, he/she can only see their own profile and perform
> the necessary actions specific to their roles.
>
> Should I be using the Admin Site? But the organization admin is really not
> a super user/staff member of the app.
>

This question is orthogonal to your other questions. Django's Admin site
isn't intended as a general purpose, user-facing administration console for
your site. It's intended for internal site administration use only.

If you're making a distinction between your own site administrators, and an
"administrator" role amongst a particular group of users/organization, then
you'll almost certainly have a separate administration interface for those
users -- but that doesn't preclude you from using Django's Admin for your
own internal administration.


> What about the User model? Should I be creating my own models?
>

Should you be creating your own Models? Almost certainly -- you'll need to
store organisation data *somewhere*.

Should you be creating your own User model? Possibly.

I can see two obvious approaches you could take.

 1) An Organization model with an m2m relation with a stock Django User.
This would allow users to belong to multiple organisations.

 2) A custom User model that has a foreign Key to Organization. This would
require every user to belong to at least one organisation (unless you make
the foreign key nullable)

Then there's the question of permissions. If every organisation will have
the same set of permissions (e.g., can create new User, can moderate
content, etc), then you can probably just use Django's own groups and
permissions model, and make sure that every time you check a permission you
also check organisation ownership.

Of course, all of this depends on the exact permissions model you want for
your own site, and ultimately only *you* can determine that.

Yours,
Russ Magee %-)

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




Re: Newbie CSRF protection questions

2013-04-14 Thread Russell Keith-Magee
On Sun, Apr 14, 2013 at 4:59 AM, Tom Christie wrote:

> One minor correction worth pointing out...
>
> "The first defense against CSRF attacks is to ensure that GET requests are
>>> side-effect free." What's meant by "side effect free"?
>>
>>
>
> It means that the request must be idempotent - that if you make the same
>> request on the server multiple times, that you get the same result each
>> time.
>
>
> That should read: "It means that the request must be 
> `safe`
> - that if you make a request it does not modify, create or delete data on
> the server".
>
> If the request is 
> idempotent or
> not isn't relevant.  In particular PUT and DELETE requests should be
> idempotent, but they are not safe, and do require CSRF protection.
>

Gah - you are, of course completely correct. My apologies to the OP for
confusing the two.

Yours,
Russ Magee %-)

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




Re: ViewDoesNotExist at /admin/

2013-04-14 Thread Russell Keith-Magee
Hi Daniel,

The error you've described isn't related to the admin site at all -- the
problem lies somewhere else in your codebase.

django.views.generic.list_detail.object_list was one of the old
function-based generic views; it was deprecated in Django 1.3, and removed
entirely in Django 1.5. You have code that is using (or at least
referencing) this old view.

Without knowing what else is in your project, or seeing the full stack
trace, it's impossible to say exactly what is causing this error. It's
possible the problem is being caused by a third party Django app that
you've included in your project.

Yours,
Russ Magee %-)

On Sat, Apr 13, 2013 at 9:15 AM, Daniel Guo  wrote:

> Hi all,
> I've spent lot of time trying to figure out what is going on there, but my
> admin site is still not working.
>
> I just followed the Django tutorial to create an app named polls. But I
> have a customized template_dir which is used by my previous app.
>
> All the configurations to activate admin site are the same from official
> tutorial. But when I am trying to access the admin site:
> http://127.0.0.1:8000/admin/
>
> I got the exceptions below:
>
> Could not import django.views.generic.list_detail.object_list. Parent module 
> django.views.generic.list_detail does not exist.
>
> Request Method:GETRequest URL:http://127.0.0.1:8000/admin/Django Version:
> 1.5.1Exception Type:ViewDoesNotExistException Value:
>
> Could not import django.views.generic.list_detail.object_list. Parent module 
> django.views.generic.list_detail does not exist.
>
> Exception 
> Location:/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py
> in get_callable, line 104Python Executable:/usr/bin/pythonPython Version:
> 2.7.3Python Path:
>
> ['/home/daniel/Django-workspace/firstProject',
>  '/usr/local/lib/python2.7/dist-packages/oauth2-1.5.211-py2.7.egg',
>  '/usr/lib/python2.7',
>  '/usr/lib/python2.7/plat-linux2',
>  '/usr/lib/python2.7/lib-tk',
>  '/usr/lib/python2.7/lib-old',
>  '/usr/lib/python2.7/lib-dynload',
>  '/usr/local/lib/python2.7/dist-packages',
>  '/usr/local/lib/python2.7/dist-packages/PIL',
>  '/usr/lib/python2.7/dist-packages',
>  '/usr/lib/python2.7/dist-packages/gst-0.10',
>  '/usr/lib/python2.7/dist-packages/gtk-2.0',
>  '/usr/lib/pymodules/python2.7',
>  '/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
>  '/usr/lib/python2.7/dist-packages/ubuntuone-client',
>  '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
>  '/usr/lib/python2.7/dist-packages/ubuntuone-couch',
>  '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol']
>
> Server time:Fri, 12 Apr 2013 20:12:16 -0500
>
>
> Not like most of the similar issues from google. I found there is
> something wrong with the 'django.views.generic.list_detail does not exist
> '??
> I am new to Django, could you please give me some hints to solve this?
>
> Thanks a lot
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: Django 1.5 with uwsgi(threaded)/mysql seems to magically cache querysets

2013-04-14 Thread budlight
using uWSGI 1.0.4 for reference

On Sunday, April 14, 2013 1:43:26 PM UTC-6, budl...@gmail.com wrote:
>
> I think this is more likely the real bug,  I saw an increase in database 
> connections as well.  
>
>
> https://groups.google.com/forum/?fromgroups=#!topic/django-users/FxTD5M0x-G8
>
> On Tuesday, April 9, 2013 8:06:18 AM UTC-6, Andy Dustman wrote:
>>
>> You know, I had another report of this, which seemed completely 
>> improbable: 
>> https://plus.google.com/u/0/101898908470597791359/posts/AuMJdgEo93k
>>
>> Maybe it's related to a bug in Django 1.5 that was fixed in 1.5.1? 
>> https://www.djangoproject.com/weblog/2013/mar/28/django-151/
>>
>>
>> On Thu, Apr 4, 2013 at 1:42 PM,  wrote:
>>
>>> I would say its definitely not isolation level, as restarting the django 
>>> instance made this issue go away for a few hours.  I would setup a test for 
>>> this, but don't really know if there already exist any per thread tests for 
>>> django sanity I could look at for examples. 
>>>
>>>
>>> The caching change is about related models, this doesn't use any real 
>>> related models, it does use them through the .values() call.  Maybe this is 
>>> a side affect of that caching, but that mentions nothing about the caching 
>>> persisting past a single request.  If that actually happens, i'm sure many 
>>> people using django 1.5 are going to run into all kinds of data loss 
>>> scenarios.  
>>>
>>>
>>> On Tuesday, April 2, 2013 11:09:19 AM UTC-6, Alan Johnson wrote:

 It's tough to know what the deal is without any info on your code or 
 database, but two things come to mind. One is some of the new caching in 
 Django 1.5 for related models (https://docs.djangoproject.**
 com/en/dev/releases/1.5/#**caching-of-related-model-**instances),
  
 and the other is database isolation level (e.g. for Postgres: 
 http://www.**postgresql.org/docs/9.1/**static/transaction-iso.html
 )

 On Monday, April 1, 2013 9:40:08 AM UTC-4, budl...@gmail.com wrote:
>
> So I have some stats reports that I run that it almost seems as if 
> each thread has its own queryset cached.  Each time I refresh they 
> change. 
>  I'm going to revert back to 1.4 due to this bug.  I wish I could come up 
> with a simple example, to demonstrate this, the problem is that the 
> underlying database needs to change between the time each thread serves a 
> request. 

  -- 
>>> 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...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>>>
>>
>>
>>
>> -- 
>> Question the answers 
>>
>

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




Re: Django 1.5 with uwsgi(threaded)/mysql seems to magically cache querysets

2013-04-14 Thread budlight
I think this is more likely the real bug,  I saw an increase in database 
connections as well.  

https://groups.google.com/forum/?fromgroups=#!topic/django-users/FxTD5M0x-G8

On Tuesday, April 9, 2013 8:06:18 AM UTC-6, Andy Dustman wrote:
>
> You know, I had another report of this, which seemed completely 
> improbable: 
> https://plus.google.com/u/0/101898908470597791359/posts/AuMJdgEo93k
>
> Maybe it's related to a bug in Django 1.5 that was fixed in 1.5.1? 
> https://www.djangoproject.com/weblog/2013/mar/28/django-151/
>
>
> On Thu, Apr 4, 2013 at 1:42 PM,  wrote:
>
>> I would say its definitely not isolation level, as restarting the django 
>> instance made this issue go away for a few hours.  I would setup a test for 
>> this, but don't really know if there already exist any per thread tests for 
>> django sanity I could look at for examples. 
>>
>>
>> The caching change is about related models, this doesn't use any real 
>> related models, it does use them through the .values() call.  Maybe this is 
>> a side affect of that caching, but that mentions nothing about the caching 
>> persisting past a single request.  If that actually happens, i'm sure many 
>> people using django 1.5 are going to run into all kinds of data loss 
>> scenarios.  
>>
>>
>> On Tuesday, April 2, 2013 11:09:19 AM UTC-6, Alan Johnson wrote:
>>>
>>> It's tough to know what the deal is without any info on your code or 
>>> database, but two things come to mind. One is some of the new caching in 
>>> Django 1.5 for related models (https://docs.djangoproject.**
>>> com/en/dev/releases/1.5/#**caching-of-related-model-**instances),
>>>  
>>> and the other is database isolation level (e.g. for Postgres: 
>>> http://www.**postgresql.org/docs/9.1/**static/transaction-iso.html
>>> )
>>>
>>> On Monday, April 1, 2013 9:40:08 AM UTC-4, budl...@gmail.com wrote:

 So I have some stats reports that I run that it almost seems as if each 
 thread has its own queryset cached.  Each time I refresh they change.  I'm 
 going to revert back to 1.4 due to this bug.  I wish I could come up with 
 a 
 simple example, to demonstrate this, the problem is that the underlying 
 database needs to change between the time each thread serves a request. 
>>>
>>>  -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>
>
> -- 
> Question the answers 
>

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




Re: Django 1.5 with uwsgi(threaded)/mysql seems to magically cache querysets

2013-04-14 Thread budlight
Odd how one guy in thread says 1.5.1 fixed it, another says SESSION 
TRANSACTION ISOLATION LEVEL READ COMMITTED, which really shouldn't fix it 
unless django is already persisting database connections per thread in 1.5, 
which isn't supposed to happen until 1.6.  The original op doesn't even 
agree its fixed either to my way of reading it, just that he agrees he 
needs to learn more about mysql. 

On Tuesday, April 9, 2013 8:06:18 AM UTC-6, Andy Dustman wrote:
>
> You know, I had another report of this, which seemed completely 
> improbable: 
> https://plus.google.com/u/0/101898908470597791359/posts/AuMJdgEo93k
>
> Maybe it's related to a bug in Django 1.5 that was fixed in 1.5.1? 
> https://www.djangoproject.com/weblog/2013/mar/28/django-151/
>
>
> On Thu, Apr 4, 2013 at 1:42 PM,  wrote:
>
>> I would say its definitely not isolation level, as restarting the django 
>> instance made this issue go away for a few hours.  I would setup a test for 
>> this, but don't really know if there already exist any per thread tests for 
>> django sanity I could look at for examples. 
>>
>>
>> The caching change is about related models, this doesn't use any real 
>> related models, it does use them through the .values() call.  Maybe this is 
>> a side affect of that caching, but that mentions nothing about the caching 
>> persisting past a single request.  If that actually happens, i'm sure many 
>> people using django 1.5 are going to run into all kinds of data loss 
>> scenarios.  
>>
>>
>> On Tuesday, April 2, 2013 11:09:19 AM UTC-6, Alan Johnson wrote:
>>>
>>> It's tough to know what the deal is without any info on your code or 
>>> database, but two things come to mind. One is some of the new caching in 
>>> Django 1.5 for related models (https://docs.djangoproject.**
>>> com/en/dev/releases/1.5/#**caching-of-related-model-**instances),
>>>  
>>> and the other is database isolation level (e.g. for Postgres: 
>>> http://www.**postgresql.org/docs/9.1/**static/transaction-iso.html
>>> )
>>>
>>> On Monday, April 1, 2013 9:40:08 AM UTC-4, budl...@gmail.com wrote:

 So I have some stats reports that I run that it almost seems as if each 
 thread has its own queryset cached.  Each time I refresh they change.  I'm 
 going to revert back to 1.4 due to this bug.  I wish I could come up with 
 a 
 simple example, to demonstrate this, the problem is that the underlying 
 database needs to change between the time each thread serves a request. 
>>>
>>>  -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>
>
> -- 
> Question the answers 
>

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




Re: PostgreSQL on windows 7 (psycopg2 install problem)

2013-04-14 Thread Mustafa Tulu
Thank you! Installing system wide did actually solve the problem.


On Sun, Apr 14, 2013 at 8:29 PM, Sanjay Bhangar wrote:

> On Windows, I'd strongly recommend just installing the pre-compiled
> binaries for these sort've things, unless you're experienced with compiling
> software / making this sort've thing work on Windows ..
>
> So, install something like
> http://www.stickpeople.com/projects/python/win-psycopg/ and then, make
> sure your virtualenv is configured to use system-site-packages. (if you are
> using the latest virtualenv, you would need to maybe re-create the
> virtualenv with "virtualenv --system-site-packages ." .. ) - just google
> virtualenv system-site-packages if that does not fully make sense :-)
>
> It's probably "better" to use pip and install it inside your virtualenv,
> but on Windows, I could never figure that out :-), and installing the .exe
> files and using --system-site-packages seems to work fine for most things
> .. it should be fairly rare that you require two different versions of
> something like psycopg2 for different projects, so it should not be
> problematic to have it installed system-wide ..
>
> All the best,
> Sanjay
>
>
>
>
> On Sun, Apr 14, 2013 at 10:17 PM, Serdar Dalgic wrote:
>
>> On Sun, Apr 14, 2013 at 5:45 PM, Mustafa Tulu 
>> wrote:
>> > Hi All,
>>
>> Hi;
>>
>> >
>> > When I try to install the package into my virtualenv in pycharm, it
>> tries to
>> > compile the source into binaries, it fails at linking stage, giving
>> errors
>> > like:
>> >  Creating library build\temp.win32-2.7\Release\psycopg\_psycopg.lib and
>> > object build\temp.win32-2.7\Release\psycopg\_psycopg.exp
>> > pqpath.obj : error LNK2019: unresolved external symbol _PQclear
>> > referenced in function _pq_raise
>> > connection_int.obj : error LNK2001: unresolved external symbol
>> _PQclear
>> > cursor_type.obj : error LNK2001: unresolved external symbol _PQclear
>> > error_type.obj : error LNK2001: unresolved external symbol _PQclear
>> > pqpath.obj : error LNK2019: unresolved external symbol
>> _PQerrorMessage
>> > referenced in function _pq_raise
>> >
>>
>> This problem is not django-specific.
>>
>> Make sure you have python-dev and libpq-dev packages installed on your
>> environment. After that, try "pip install psycopg2"
>>
>> --
>> - Serdar Dalgıç 
>> FLOSS Developer, Life & Nature Hacker
>> twitter: https://twitter.com/serdaroncode
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: PostgreSQL on windows 7 (psycopg2 install problem)

2013-04-14 Thread Avraham Serour
I usually try to compile the packages on my win7 machine, just so I can use
pip install inside my virtualenv.
psycopg2 was the only one so far that I couldn't, eventually I installed
the pre compiled binaries on my root python installation and then copied
the files/folder necessary for psycopg2 from site-packages (from my root
python to the virtual env)


On Sun, Apr 14, 2013 at 8:29 PM, Sanjay Bhangar wrote:

> On Windows, I'd strongly recommend just installing the pre-compiled
> binaries for these sort've things, unless you're experienced with compiling
> software / making this sort've thing work on Windows ..
>
> So, install something like
> http://www.stickpeople.com/projects/python/win-psycopg/ and then, make
> sure your virtualenv is configured to use system-site-packages. (if you are
> using the latest virtualenv, you would need to maybe re-create the
> virtualenv with "virtualenv --system-site-packages ." .. ) - just google
> virtualenv system-site-packages if that does not fully make sense :-)
>
> It's probably "better" to use pip and install it inside your virtualenv,
> but on Windows, I could never figure that out :-), and installing the .exe
> files and using --system-site-packages seems to work fine for most things
> .. it should be fairly rare that you require two different versions of
> something like psycopg2 for different projects, so it should not be
> problematic to have it installed system-wide ..
>
> All the best,
> Sanjay
>
>
>
>
> On Sun, Apr 14, 2013 at 10:17 PM, Serdar Dalgic wrote:
>
>> On Sun, Apr 14, 2013 at 5:45 PM, Mustafa Tulu 
>> wrote:
>> > Hi All,
>>
>> Hi;
>>
>> >
>> > When I try to install the package into my virtualenv in pycharm, it
>> tries to
>> > compile the source into binaries, it fails at linking stage, giving
>> errors
>> > like:
>> >  Creating library build\temp.win32-2.7\Release\psycopg\_psycopg.lib and
>> > object build\temp.win32-2.7\Release\psycopg\_psycopg.exp
>> > pqpath.obj : error LNK2019: unresolved external symbol _PQclear
>> > referenced in function _pq_raise
>> > connection_int.obj : error LNK2001: unresolved external symbol
>> _PQclear
>> > cursor_type.obj : error LNK2001: unresolved external symbol _PQclear
>> > error_type.obj : error LNK2001: unresolved external symbol _PQclear
>> > pqpath.obj : error LNK2019: unresolved external symbol
>> _PQerrorMessage
>> > referenced in function _pq_raise
>> >
>>
>> This problem is not django-specific.
>>
>> Make sure you have python-dev and libpq-dev packages installed on your
>> environment. After that, try "pip install psycopg2"
>>
>> --
>> - Serdar Dalgıç 
>> FLOSS Developer, Life & Nature Hacker
>> twitter: https://twitter.com/serdaroncode
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: Dynamic runtime modeling: which is the best choice?

2013-04-14 Thread Max Demars
Hi Alessandro,

How your searches are going so far? Have you found something interresting 
with Dynamic-Models such Django-Mutant? I am exactly looking for the same 
thing you mentioned in this post, a solution that will allow Django ORM to 
manipulate uploaded shapefiles. So far, I have found a generic way as 
Andres Reyes Monge was talking about but I would prefer a table per 
shapefile also.

I was thinking about giving a try to django-mutant, so I would like to know 
if it works for you. Other idea I have is to use ogrinspect to update a 
models.py on every upload/delete of a shapefile maybe combining with a 
queue like Celery. I am not sure neither about this avenue.

Please give me a little feedback about this topic!

Max Demars

On Tuesday, January 31, 2012 10:15:44 AM UTC-5, Alessandro Candini wrote:
>
> Hi list.
> I need to create an app in which the user can upload a shapefile, which 
> must be stored in a database table with LayerMapping from 
> django.contrib.gis.utils, as explained here:
>
> https://docs.djangoproject.com/en/dev/ref/contrib/gis/tutorial/#layermapping
>
> The problem is that I need to update dynamically my models.py with a new 
> model and add a table for every shape inserted by the user, without 
> using syncdb.
>
> Trying to document myself about this topic, I encountered a lot of 
> interesting extensions like south, django-eav and django-mutant for 
> example.
> (An interesting discussion here: 
>
> http://stackoverflow.com/questions/7933596/django-dynamic-model-fields/7934577#7934577
> )
>
> But I'm very confused about what could be the best solution for my needs.
>
> Has anybody experience with this kind of tools?
>
> Thanks in advance.
>
> Alessandro
>
>

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




Re: PostgreSQL on windows 7 (psycopg2 install problem)

2013-04-14 Thread Sanjay Bhangar
On Windows, I'd strongly recommend just installing the pre-compiled
binaries for these sort've things, unless you're experienced with compiling
software / making this sort've thing work on Windows ..

So, install something like
http://www.stickpeople.com/projects/python/win-psycopg/ and then, make sure
your virtualenv is configured to use system-site-packages. (if you are
using the latest virtualenv, you would need to maybe re-create the
virtualenv with "virtualenv --system-site-packages ." .. ) - just google
virtualenv system-site-packages if that does not fully make sense :-)

It's probably "better" to use pip and install it inside your virtualenv,
but on Windows, I could never figure that out :-), and installing the .exe
files and using --system-site-packages seems to work fine for most things
.. it should be fairly rare that you require two different versions of
something like psycopg2 for different projects, so it should not be
problematic to have it installed system-wide ..

All the best,
Sanjay




On Sun, Apr 14, 2013 at 10:17 PM, Serdar Dalgic  wrote:

> On Sun, Apr 14, 2013 at 5:45 PM, Mustafa Tulu 
> wrote:
> > Hi All,
>
> Hi;
>
> >
> > When I try to install the package into my virtualenv in pycharm, it
> tries to
> > compile the source into binaries, it fails at linking stage, giving
> errors
> > like:
> >  Creating library build\temp.win32-2.7\Release\psycopg\_psycopg.lib and
> > object build\temp.win32-2.7\Release\psycopg\_psycopg.exp
> > pqpath.obj : error LNK2019: unresolved external symbol _PQclear
> > referenced in function _pq_raise
> > connection_int.obj : error LNK2001: unresolved external symbol
> _PQclear
> > cursor_type.obj : error LNK2001: unresolved external symbol _PQclear
> > error_type.obj : error LNK2001: unresolved external symbol _PQclear
> > pqpath.obj : error LNK2019: unresolved external symbol
> _PQerrorMessage
> > referenced in function _pq_raise
> >
>
> This problem is not django-specific.
>
> Make sure you have python-dev and libpq-dev packages installed on your
> environment. After that, try "pip install psycopg2"
>
> --
> - Serdar Dalgıç 
> FLOSS Developer, Life & Nature Hacker
> twitter: https://twitter.com/serdaroncode
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: PostgreSQL on windows 7 (psycopg2 install problem)

2013-04-14 Thread Serdar Dalgic
On Sun, Apr 14, 2013 at 5:45 PM, Mustafa Tulu  wrote:
> Hi All,

Hi;

>
> When I try to install the package into my virtualenv in pycharm, it tries to
> compile the source into binaries, it fails at linking stage, giving errors
> like:
>  Creating library build\temp.win32-2.7\Release\psycopg\_psycopg.lib and
> object build\temp.win32-2.7\Release\psycopg\_psycopg.exp
> pqpath.obj : error LNK2019: unresolved external symbol _PQclear
> referenced in function _pq_raise
> connection_int.obj : error LNK2001: unresolved external symbol _PQclear
> cursor_type.obj : error LNK2001: unresolved external symbol _PQclear
> error_type.obj : error LNK2001: unresolved external symbol _PQclear
> pqpath.obj : error LNK2019: unresolved external symbol _PQerrorMessage
> referenced in function _pq_raise
>

This problem is not django-specific.

Make sure you have python-dev and libpq-dev packages installed on your
environment. After that, try "pip install psycopg2"

-- 
- Serdar Dalgıç 
FLOSS Developer, Life & Nature Hacker
twitter: https://twitter.com/serdaroncode

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




Understanding users auth in Django

2013-04-14 Thread Nora Olsen
Hi,

I'm using Django 1.5 and I have looked at guardian / Userena / pinax user 
accounts but I'm not sure how they work with the authentication mechanism 
in Django.

I'm creating a site that typically have the following the groups :
1. Super Admin: Myself
2. Organization admin. This is created by super admin only. 
3. Organization user group: A, B, C, such as editors, moderators, finance, 
hr, etc

These user groups have the same role regardless of the organization. 

This is similar to most site, such as mailchimp/mixpanel/aws/etc, that the 
first account is an admin account. Using that admin account, the user will 
be able to create other accounts and assign roles to them. Roles come with 
fix set of permissions across the entire site. 

I'm trying to create a typical site with a login page with email & 
password. Upon login, the organization admin would be able to access the 
"Organization accounts" under his/her dashboard to manage their users.

If it's a normal user, he/she can only see their own profile and perform 
the necessary actions specific to their roles.

Should I be using the Admin Site? But the organization admin is really not 
a super user/staff member of the app. 

What about the User model? Should I be creating my own models? 

Any pointers?

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




Re: Reading xpath value error - Lxml

2013-04-14 Thread no body
Wow, thank you so so much for reminding me about the "tbody". This works
well now !!!


On Sun, Apr 14, 2013 at 7:27 PM, Tom Evans  wrote:

> On Sun, Apr 14, 2013 at 10:29 AM,   wrote:
> > Hi all,
> >
> > I am trying to crawl the information from this link
> >
> >
> http://muaban.net/mua-ban-nha-quan-thu-duc-l5924-c32/quan-thu-duc-ban-nha1lau-2mt-truoc-sau-dg-ng-cong-tru-p-hiep-phu-q9-dt-4x21-5m--id15946781
> >
> > and this is the code I use
> >
> >> link =
> >> "
> http://muaban.net/mua-ban-nha-quan-thu-duc-l5924-c32/quan-thu-duc-ban-nha1lau-2mt-truoc-sau-dg-ng-cong-tru-p-hiep-phu-q9-dt-4x21-5m--id15946781
> "
> >> xPath =  "id('pC_DV_tableHeader')/x:tbody/x:tr[4]/x:td[3]"
> >> namespace = {'x': 'http://www.w3.org/1999/xhtml'}
> >>
> >> tree = lxml.html.parse(link)
> >> arrayContent = tree.xpath(xPath + "/text()", namespaces=namespace)
> >>
> >> if len(arrayContent):
> >>  content = cgi.escape(arrayContent[0].encode("utf-8"))
> >
> >
> > I use xPath checker add-on of firefox to read the xPath value and the
> > namespace. However, when running the code, I always get the content
> empty.
> > How can I solve this ?
> >
>
> Are you sure your xpath is correct? I'm not sure about that "id()" syntax.
> Try:
>
> //x:table[@id="'pC_DV_tableHeader"]//x:tr[4]/x:td[3]
>
> Another thing to note, the DOM presented by Firefox is the result of
> Firefox parsing and potentially fixing up the HTML code. For instance,
> there is no  in the actual HTML for that table, Firefox always
> inserts a  if it is missing  when parsing a table. Does lxml
> also insert a  if there is not one? If it doesn't, then your
> xpath would never work.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




PostgreSQL on windows 7 (psycopg2 install problem)

2013-04-14 Thread Mustafa Tulu
Hi All,

I am very new on the subject. Trying to run a postgresql backend with
django. (sqllite3 is said to cause problems)

My google searches do not reveal useful links on how to do it.

I met problems with "pip install psycopg2".

When I try to install the package into my virtualenv in pycharm, it tries
to compile the source into binaries, it fails at linking stage, giving
errors like:
 Creating library build\temp.win32-2.7\Release\psycopg\_psycopg.lib and
object build\temp.win32-2.7\Release\psycopg\_psycopg.exp
pqpath.obj : error LNK2019: unresolved external symbol _PQclear
referenced in function _pq_raise
connection_int.obj : error LNK2001: unresolved external symbol _PQclear
cursor_type.obj : error LNK2001: unresolved external symbol _PQclear
error_type.obj : error LNK2001: unresolved external symbol _PQclear
pqpath.obj : error LNK2019: unresolved external symbol _PQerrorMessage
referenced in function _pq_raise



I have also tried to copy the binaries into my virtualenv.

I still get
"Error: No module named psycopg2.extensions" error.

Does anybody have a working solution?

Regards

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




How to take ForeignKey fields as TextInputs in Forms

2013-04-14 Thread surya
# models.py 

class Model1 (models.Model):
 a = models.CharField()
 b = models.CharField()

class Model2 (models.Model):
 c = models.CharField()
 ab = models.ForeignKey(Model1)

# forms.py 

class Form(ModelForm):
 class Meta:
 model = Model2
 fields  = ('ab')
 widgets = {'ab' : TextInput()}

I want to display a,b fields as TextInputs and not as Options which is 
observed by default. However, If I provide TextInput() widget explicitly, 
the 'ab' field is working as a single textinput. .

I want to display a, b fields as two textinput's.. how to do that?



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




Re: django form

2013-04-14 Thread Harjot Mann
done with it.thnks


On Sun, Apr 14, 2013 at 12:09 PM, Enator24  wrote:

>
>
> On Saturday, 13 April 2013 20:25:00 UTC+5:30, Harjot Mann wrote:
>>
>> I have made a form in models.py file and displayed using html and  i want
>> that when i submit after filling, it should refer to another html file
>> displaying the mesage that form data is filled but it is showing an error
>> can anyone help me please??
>>
>
> Hi Harjot , Can you send the error message.
>
> You have to create a forms.py file to display the form and views.py for
> the function to processthe form data and redirect to thank you page or
> return to the same form.
>
> If possible explain the steps you r following.
>
> Regards,
> Enator
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: Reading xpath value error - Lxml

2013-04-14 Thread Tom Evans
On Sun, Apr 14, 2013 at 10:29 AM,   wrote:
> Hi all,
>
> I am trying to crawl the information from this link
>
> http://muaban.net/mua-ban-nha-quan-thu-duc-l5924-c32/quan-thu-duc-ban-nha1lau-2mt-truoc-sau-dg-ng-cong-tru-p-hiep-phu-q9-dt-4x21-5m--id15946781
>
> and this is the code I use
>
>> link =
>> "http://muaban.net/mua-ban-nha-quan-thu-duc-l5924-c32/quan-thu-duc-ban-nha1lau-2mt-truoc-sau-dg-ng-cong-tru-p-hiep-phu-q9-dt-4x21-5m--id15946781;
>> xPath =  "id('pC_DV_tableHeader')/x:tbody/x:tr[4]/x:td[3]"
>> namespace = {'x': 'http://www.w3.org/1999/xhtml'}
>>
>> tree = lxml.html.parse(link)
>> arrayContent = tree.xpath(xPath + "/text()", namespaces=namespace)
>>
>> if len(arrayContent):
>>  content = cgi.escape(arrayContent[0].encode("utf-8"))
>
>
> I use xPath checker add-on of firefox to read the xPath value and the
> namespace. However, when running the code, I always get the content empty.
> How can I solve this ?
>

Are you sure your xpath is correct? I'm not sure about that "id()" syntax. Try:

//x:table[@id="'pC_DV_tableHeader"]//x:tr[4]/x:td[3]

Another thing to note, the DOM presented by Firefox is the result of
Firefox parsing and potentially fixing up the HTML code. For instance,
there is no  in the actual HTML for that table, Firefox always
inserts a  if it is missing  when parsing a table. Does lxml
also insert a  if there is not one? If it doesn't, then your
xpath would never work.

Cheers

Tom

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




Re: Reset Demo Database Data (with Dates)

2013-04-14 Thread Joey Espinosa
Well I'll be giving this a shot maybe this week. You might be getting some
pull requests ;)

--
Joey "JoeLinux" Espinosa
Python Developer
http://about.me/joelinux
On Apr 14, 2013 8:09 AM, "Tom Evans"  wrote:

> On Sun, Apr 14, 2013 at 7:15 AM, Joey Espinosa
>  wrote:
> >
> > Did you just write that or you happened to find what my own Google Fu
> could not? If the former, then I owe you a beer. I'll definitely give this
> a shot on Monday. Thanks!
> >
>
> Yeah, I got intrigued :) It's only 60 lines or so, and I think you're
> right, it is a useful tool to have in your armoury for demos.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: Reset Demo Database Data (with Dates)

2013-04-14 Thread Tom Evans
On Sun, Apr 14, 2013 at 7:15 AM, Joey Espinosa
 wrote:
>
> Did you just write that or you happened to find what my own Google Fu could 
> not? If the former, then I owe you a beer. I'll definitely give this a shot 
> on Monday. Thanks!
>

Yeah, I got intrigued :) It's only 60 lines or so, and I think you're
right, it is a useful tool to have in your armoury for demos.

Cheers

Tom

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




Reading xpath value error - Lxml

2013-04-14 Thread bubufff
Hi all, 

I am trying to crawl the information from this link 

http://muaban.net/mua-ban-nha-quan-thu-duc-l5924-c32/quan-thu-duc-ban-nha1lau-2mt-truoc-sau-dg-ng-cong-tru-p-hiep-phu-q9-dt-4x21-5m--id15946781

and this is the code I use

link = 
> "http://muaban.net/mua-ban-nha-quan-thu-duc-l5924-c32/quan-thu-duc-ban-nha1lau-2mt-truoc-sau-dg-ng-cong-tru-p-hiep-phu-q9-dt-4x21-5m--id15946781;
> xPath =  "id('pC_DV_tableHeader')/x:tbody/x:tr[4]/x:td[3]"
> namespace = {'x': 'http://www.w3.org/1999/xhtml'}
>
> tree = lxml.html.parse(link)
> arrayContent = tree.xpath(xPath + "/text()", namespaces=namespace)
>
> if len(arrayContent):
>  content = cgi.escape(arrayContent[0].encode("utf-8"))
>

I use xPath checker add-on of firefox to read the xPath value and the 
namespace. However, when running the code, I always get the content empty. 
How can I solve this ?  

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




Re: django form

2013-04-14 Thread Enator24


On Saturday, 13 April 2013 20:25:00 UTC+5:30, Harjot Mann wrote:
>
> I have made a form in models.py file and displayed using html and  i want 
> that when i submit after filling, it should refer to another html file 
> displaying the mesage that form data is filled but it is showing an error
> can anyone help me please??
>

Hi Harjot , Can you send the error message.

You have to create a forms.py file to display the form and views.py for the 
function to processthe form data and redirect to thank you page or return 
to the same form.

If possible explain the steps you r following.

Regards,
Enator

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




Re: Reset Demo Database Data (with Dates)

2013-04-14 Thread Joey Espinosa
Did you just write that or you happened to find what my own Google Fu could
not? If the former, then I owe you a beer. I'll definitely give this a shot
on Monday. Thanks!

--
Joey "JoeLinux" Espinosa*
*




On Sat, Apr 13, 2013 at 11:22 PM, Tom Evans wrote:

> On Sat, Apr 13, 2013 at 12:25 PM, Joey Espinosa
>  wrote:
> > Thanks, Tom. I'm familiar with fixtures. My problem is that I don't know
> > which fields exactly will be date fields (so I have to check each model
> for
> > those fields), and then increment them according to the current date
> (which
> > will change every day).
>
> I don't understand this - are your models dynamic? Surely you know
> which models have date fields, you know what objects you want to
> create with your fixtures.
>
> >
> > So if a demo happens on the 9th, and my field is set to the 15th, then
> > tomorrow when I reset the data that field must be set to the 16th
> (because
> > the date would now be the 10th). Then on the next day, after the data has
> > been reset, that field would need to change to be the 17th (because the
> > current date would be the 11th). Similarly, I'd have to do the same with
> > every other date in the database, without knowing exactly which fields I
> > have to change (I only know which "type" of field needs to change), and
> > without knowing when exactly the database needs to be reset (could be
> twice
> > a day, once a day, etc... I can't assume the current date will be
> different
> > every time this reset happens).
>
> Each time you want to reset the data for a demo, you clear the
> database. You then reload your fixtures. Because any object with a
> date is loaded from a SQL fixture, with the date being relative to
> todays date, the dates will be correct for the next demo.
>
> You've just got to go through your fixtures, work out which models -
> and particular instances of those models - want to have dynamic dates,
> and migrate those objects to an SQL fixture. I suppose if you have a
> lot of date fields/instance that could be a lot of work..
>
> >
> > That's my issue in a nutshell. I will have an initial fixture for the
> data,
> > and I'll probably have to store the date the initial fixture (the
> baseline)
> > was created. That would give me the appropriate date from which to take a
> > "delta" (i.e., this field is +5 days, this other field is -41 days, etc).
> > Then, when the data is reset back to that fixture, I'd have to go through
> > all the data and find any date, and adjust it to the current date
> (whatever
> > that may be) according to that field's "delta" (i.e., +5 days from today,
> > -41 days from today, etc).
> >
> > This way the "state" of every object in the database remains the same as
> it
> > is on any other day, because the ONLY variable that ever changes in a
> > database dump is its relationship to the current date (time always
> changes).
> > I need to keep that consistency to ensure that demos with potential
> clients
> > always follow the exact same "pitch" (otherwise there may be an expired
> > object over here, a process that may have already happened over there, an
> > event that is no longer in the future, etc).
> >
> > I'm honestly just surprised that nobody has ever encountered a scenario
> > where they would need something like this before in Django. I can't be
> the
> > only one running scripted demos of a product with potential clients.
> Seems
> > like there would be a "django-demo" app for this or something. If you
> guys
> > help me figure out a good way to do this, I'll be happy to distribute it
> on
> > PyPi.
> >
> > Thanks again for the help guys.
> >
>
> Hmm, ok. Something that iterates through each model installed, checks
> its fields to see if it is a date field, and then rebases it based
> upon todays date and the date of the previous demo (so it knows the
> date is demo date + N). Try this, it's fairly naive, but it does the
> trick.
>
> https://github.com/tevansuk/django-demo-reset
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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