django UserAdmin

2014-10-07 Thread Sachin Tiwari
Hi,

I added an extra field phone number in existiing user model and now I 
tyring to access that field by below method,

 UserAdmin.list_display = ('email', 'first_name', 'last_name','is_staff', 
SMSRegistration.phone_no)

type object 'SMSRegistration' has no attribute 'phone_no'


Please 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/1f3b93e4-8764-475e-99f6-24873af5dc83%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Show a model on the admin list index page

2014-10-07 Thread Daniel Rus Morales
Hi Andrea,

I answer below in between lines.

On 07 Oct 2014, at 08:53, Andrea  wrote:

> Let's suppose I have a Foo app with a Bar model with a owner field. I want a 
> user to be able to edit all the instances for which obj.owner == request.user.
> 
> The model appears correctly in the admin panel for superusers and for users 
> for which I have explicitly assigned the permission change_bar or add_bar, as 
> explained here:
> 
> Assuming you have an application with an app_label foo and a model named Bar, 
> to test for basic permissions you should use:
> 
> add: user.has_perm('foo.add_bar')
> change: user.has_perm('foo.change_bar')
> delete: user.has_perm('foo.delete_bar')
> How can I show the model Bar in the admin index list without explicitly 
> assigning foo.change_bar or foo.add_bar to the user?
> 
> 

You can’t. The admin interface of Django assumes that when a user has access to 
the administrative interface of an App-Model it’s not to act as a mere passive 
consumer with read-only access but rather as an active admin over the content 
(add, change, delete). An administrator who does only inspect or supervise the 
content doesn’t fit in the sort of administrator that the Django administration 
app allows. It’s like allowing an administrator who actually does not 
administer. 

> So far I tried the following, expecting the Bar model to appear in the index 
> list page, but it didn't work.
> 
> class BarAdmin(admin.ModelAdmin):
> def get_queryset(self, request):
> qs = super(BarAdmin, self).get_queryset(request)
> if request.user.is_superuser:
> return qs
> return qs.filter(owner=request.user)
> 
> def has_add_permission(self, request):
> return True
> 
> def has_change_permission(self, request, obj=None):
> if obj is None:
> return True
> if obj.owner == request.user:
> return True
> return False
> 
> def has_delete_permission(self, request, obj=None):
> if obj is None:
> return True
> if obj.owner == request.user:
> return True
> return False
> 
> def has_module_permission(self, request):
> return True
> Accessing the link admin/foo/bar/ works correctly for every user and returns 
> the list of Bar instances for which obj.owner == request.user. 
> admin/foo/bar/add allows the user to add a new object correctly. These links 
> are although not displayed in the admin index page: which is the function 
> that triggers the appearance of the model in the index page? admin/foo/ 
> returns 403 Forbidden.
> 

Uhm… this looks strange to me. So you don’t want to provide the user with 
add/change/delete permissions but you are faking them. 

The Bar model doesn’t appear in the App index list page because the view 
function in charge first verifies whether the user has any of the 
add/change/delete permissions granted for such App, and given that your user 
doesn’t have them the App Foo is not listed. In other words, you would have to 
override the index admin view too (in django.contrib.admin.sites.py), which I 
don’t recommend. Think that by overriding the way permissions are handled in 
the admin interface you might end up giving change access to regular users that 
shouldn’t have access at all. 

My recommendation here is to create your own supervising interface for Foo, 
with its own URLs, to provide the readonly functionality your target users 
needs. Those users might not probably fall in the category of admins. I’m 
thinking in maybe managers who need to see what’s going on but doesn’t have to 
have write access.

Does this answer your questions?

> I'm using Django 1.7
> 
> Thanks,
> 
> Andrea
> 
> 

Cheers,
Daniel



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: Show a model on the admin list index page

2014-10-07 Thread Andrea
Dear Daniel,

thank you for your answer.
I think I was not clear enough in explaining my problem. I will try to
rephrase the problem, please tell me if from the first message this point
was clear or seemed different.

I do want that the user is able to add or change some objects. My goal is
to bypass the django admin permission system, and overriding
"has_*_permission" methods seemed the correct option.

The following example is correlated but a bit simpler. Let's suppose I
grant the access to all the users to the admin panel (is_staff=True for
each user).

Now I want them to be able to add an instance of Bar model.

class BarAdmin(admin.ModelAdmin):
def has_add_permission(self, request):
return True

def has_module_permission(self, request):
return True

In my opinion that should do the trick, in fact the link to add a new
instance is enabled, but it's not shown in the admin index page (and that's
my problem).
What I do not want to do is to specifically assign the `foo.add_bar`
permission under the `permissions` section in the user profile for each
user.

Thanks for your time spent in tackling this issue.

Andrea

2014-10-07 11:01 GMT+02:00 Daniel Rus Morales :

> Hi Andrea,
>
> I answer below in between lines.
>
> On 07 Oct 2014, at 08:53, Andrea  wrote:
>
> Let's suppose I have a Foo app with a Bar model with a owner field. I
> want a user to be able to edit all the instances for which obj.owner ==
> request.user.
>
> The model appears correctly in the admin panel for superusers and for
> users for which I have explicitly assigned the permission change_bar or
> add_bar, as explained here
> 
> :
>
> Assuming you have an application with an app_label foo and a model named
> Bar, to test for basic permissions you should use:
>
> add: user.has_perm('foo.add_bar')
> change: user.has_perm('foo.change_bar')
> delete: user.has_perm('foo.delete_bar')
>
> How can I show the model Bar in the admin index list without explicitly
> assigning foo.change_bar or foo.add_bar to the user?
>
>
> You can’t. The admin interface of Django assumes that when a user has
> access to the administrative interface of an App-Model it’s not to act as a
> mere passive consumer with read-only access but rather as an active admin
> over the content (add, change, delete). An administrator who does only
> inspect or supervise the content doesn’t fit in the sort of administrator
> that the Django administration app allows. It’s like allowing an
> administrator who actually does not administer.
>
> So far I tried the following, expecting the Bar model to appear in the
> index list page, but it didn't work.
>
> class BarAdmin(admin.ModelAdmin):
> def get_queryset(self, request):
> qs = super(BarAdmin, self).get_queryset(request)
> if request.user.is_superuser:
> return qs
> return qs.filter(owner=request.user)
>
> def has_add_permission(self, request):
> return True
>
> def has_change_permission(self, request, obj=None):
> if obj is None:
> return True
> if obj.owner == request.user:
> return True
> return False
>
> def has_delete_permission(self, request, obj=None):
> if obj is None:
> return True
> if obj.owner == request.user:
> return True
> return False
>
> def has_module_permission(self, request):
> return True
>
> Accessing the link admin/foo/bar/ works correctly for every user and
> returns the list of Bar instances for which obj.owner == request.user.
> admin/foo/bar/add allows the user to add a new object correctly. These
> links are although not displayed in the admin index page: which is the
> function that triggers the appearance of the model in the index page?
> admin/foo/ returns 403 Forbidden.
>
>
> Uhm… this looks strange to me. So you don’t want to provide the user with
> add/change/delete permissions but you are faking them.
>
> The Bar model doesn’t appear in the App index list page because the view
> function in charge first verifies whether the user has any of the
> add/change/delete permissions granted for such App, and given that your
> user doesn’t have them the App Foo is not listed. In other words, you would
> have to override the index admin view too (in
> django.contrib.admin.sites.py), which I don’t recommend. Think that by
> overriding the way permissions are handled in the admin interface you might
> end up giving change access to regular users that shouldn’t have access at
> all.
>
> My recommendation here is to create your own supervising interface for
> Foo, with its own URLs, to provide the readonly functionality your target
> users needs. Those users might not probably fall in the category of admins.
> I’m thinking in maybe managers who need to see what’s going on but doesn’t
> have to have write access.
>
> Does this answer your questions

Re: Show a model on the admin list index page

2014-10-07 Thread Andrea
Dear Daniel,

I want to answer to an issue you raised in your previous message.

The Bar model doesn’t appear in the App index list page because the view
> function in charge first verifies whether the user has any of the
> add/change/delete permissions granted for such App, and given that your
> user doesn’t have them the App Foo is not listed.
>

This is the point I don't understand. I granted the user the add permission
for the model, overriding the "has_add_permission" method for the admin
model. In fact the add link can be manually reached and works properly.
Which is the function in charge of checking for which models the user has
permissions in the admin index page? I could override that one as well, as
I did for the model with "has_add_permission".

Thanks,
Andrea

-- 
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/CAAPQ7Y1%3D6pTaHDgwU8vSiP_cT4%3Dcs641xTZ4oFju-hfdCAgD0g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Show a model on the admin list index page

2014-10-07 Thread Daniel Rus Morales
I think it’s clear to me what you are trying to do. By overriding those methods 
in BarAdmin you go down that line (bypass the django admin permission system), 
but to get the app listed in the admin index page you would have to actually 
rewrite the view function. This view function makes an explicit verification on 
the add/change/delete permissions for the logged in user and app Foo, and as 
long as your users don’t have them granted for such app they can’t see it 
listed.

Going back to my concern on overriding the permissions system, have you 
considered getting the functionality by providing your staff users with 
permissions at app Foo configuration time? That way your users would get access 
and you would write less code. You would create a group and would assign 
permissions to the group. At AppConfig.ready() you could assign your users to 
the new group, and thus grant them access.

Best,
Daniel


On 07 Oct 2014, at 11:25, Andrea  wrote:

> Dear Daniel,
> 
> thank you for your answer.
> I think I was not clear enough in explaining my problem. I will try to 
> rephrase the problem, please tell me if from the first message this point was 
> clear or seemed different.
> 
> I do want that the user is able to add or change some objects. My goal is to 
> bypass the django admin permission system, and overriding "has_*_permission" 
> methods seemed the correct option.
> 
> The following example is correlated but a bit simpler. Let's suppose I grant 
> the access to all the users to the admin panel (is_staff=True for each user).
> 
> Now I want them to be able to add an instance of Bar model.
> 
> class BarAdmin(admin.ModelAdmin):
> def has_add_permission(self, request):
> return True
> def has_module_permission(self, request):
> return True
> In my opinion that should do the trick, in fact the link to add a new 
> instance is enabled, but it's not shown in the admin index page (and that's 
> my problem).
> What I do not want to do is to specifically assign the `foo.add_bar` 
> permission under the `permissions` section in the user profile for each user.
> 
> Thanks for your time spent in tackling this issue.
> 
> Andrea
> 
> 2014-10-07 11:01 GMT+02:00 Daniel Rus Morales :
> Hi Andrea,
> 
> I answer below in between lines.
> 
> On 07 Oct 2014, at 08:53, Andrea  wrote:
> 
>> Let's suppose I have a Foo app with a Bar model with a owner field. I want a 
>> user to be able to edit all the instances for which obj.owner == 
>> request.user.
>> 
>> The model appears correctly in the admin panel for superusers and for users 
>> for which I have explicitly assigned the permission change_bar or add_bar, 
>> as explained here:
>> 
>> Assuming you have an application with an app_label foo and a model named 
>> Bar, to test for basic permissions you should use:
>> 
>> add: user.has_perm('foo.add_bar')
>> change: user.has_perm('foo.change_bar')
>> delete: user.has_perm('foo.delete_bar')
>> How can I show the model Bar in the admin index list without explicitly 
>> assigning foo.change_bar or foo.add_bar to the user?
>> 
>> 
> 
> You can’t. The admin interface of Django assumes that when a user has access 
> to the administrative interface of an App-Model it’s not to act as a mere 
> passive consumer with read-only access but rather as an active admin over the 
> content (add, change, delete). An administrator who does only inspect or 
> supervise the content doesn’t fit in the sort of administrator that the 
> Django administration app allows. It’s like allowing an administrator who 
> actually does not administer. 
> 
>> So far I tried the following, expecting the Bar model to appear in the index 
>> list page, but it didn't work.
>> 
>> class BarAdmin(admin.ModelAdmin):
>> def get_queryset(self, request):
>> qs = super(BarAdmin, self).get_queryset(request)
>> if request.user.is_superuser:
>> return qs
>> return qs.filter(owner=request.user)
>> 
>> def has_add_permission(self, request):
>> return True
>> 
>> def has_change_permission(self, request, obj=None):
>> if obj is None:
>> return True
>> if obj.owner == request.user:
>> return True
>> return False
>> 
>> def has_delete_permission(self, request, obj=None):
>> if obj is None:
>> return True
>> if obj.owner == request.user:
>> return True
>> return False
>> 
>> def has_module_permission(self, request):
>> return True
>> Accessing the link admin/foo/bar/ works correctly for every user and returns 
>> the list of Bar instances for which obj.owner == request.user. 
>> admin/foo/bar/add allows the user to add a new object correctly. These links 
>> are although not displayed in the admin index page: which is the function 
>> that triggers the appearance of the model in the index page? admin/foo/ 
>> returns 403 Forbidden.
>> 
> 
> Uhm… this looks strange to me. So you d

Re: Show a model on the admin list index page

2014-10-07 Thread Andrea
I think I've found the problem.

In my Django version I have in `contrib/admin/sites.py` line 371:

has_module_perms = user.has_module_perms(app_label)

Here it is instead:

https://github.com/django/django/blob/master/django/contrib/admin/sites.py
line 383:
has_module_perms = model_admin.has_module_permission(request)

I was probably reading the dev documentation of something that's not in
Django 1.7 but will be in Django 1.8.

https://github.com/django/django/commit/504c89e8008c557a1e83c45535b549f77a3503b2

Thanks!
Andrea

2014-10-07 11:54 GMT+02:00 Daniel Rus Morales :

> I think it’s clear to me what you are trying to do. By overriding those
> methods in BarAdmin you go down that line (bypass the django admin
> permission system), but to get the app listed in the admin index page you
> would have to actually rewrite the view function. This view function makes
> an explicit verification on the add/change/delete permissions for the
> logged in user and app Foo, and as long as your users don’t have them
> granted for such app they can’t see it listed.
>
> Going back to my concern on overriding the permissions system, have you
> considered getting the functionality by providing your staff users with
> permissions at app Foo configuration time? That way your users would get
> access and you would write less code. You would create a group and would
> assign permissions to the group. At AppConfig.ready() you could assign your
> users to the new group, and thus grant them access.
>
> Best,
> Daniel
>
>
> On 07 Oct 2014, at 11:25, Andrea  wrote:
>
> Dear Daniel,
>
> thank you for your answer.
> I think I was not clear enough in explaining my problem. I will try to
> rephrase the problem, please tell me if from the first message this point
> was clear or seemed different.
>
> I do want that the user is able to add or change some objects. My goal is
> to bypass the django admin permission system, and overriding
> "has_*_permission" methods seemed the correct option.
>
> The following example is correlated but a bit simpler. Let's suppose I
> grant the access to all the users to the admin panel (is_staff=True for
> each user).
>
> Now I want them to be able to add an instance of Bar model.
>
> class BarAdmin(admin.ModelAdmin):
> def has_add_permission(self, request):
> return True
>
> def has_module_permission(self, request):
> return True
>
> In my opinion that should do the trick, in fact the link to add a new
> instance is enabled, but it's not shown in the admin index page (and that's
> my problem).
> What I do not want to do is to specifically assign the `foo.add_bar`
> permission under the `permissions` section in the user profile for each
> user.
>
> Thanks for your time spent in tackling this issue.
>
> Andrea
>
> 2014-10-07 11:01 GMT+02:00 Daniel Rus Morales :
>
>> Hi Andrea,
>>
>> I answer below in between lines.
>>
>> On 07 Oct 2014, at 08:53, Andrea  wrote:
>>
>> Let's suppose I have a Foo app with a Bar model with a owner field. I
>> want a user to be able to edit all the instances for which obj.owner ==
>> request.user.
>>
>> The model appears correctly in the admin panel for superusers and for
>> users for which I have explicitly assigned the permission change_bar or
>> add_bar, as explained here
>> 
>> :
>>
>> Assuming you have an application with an app_label foo and a model named
>> Bar, to test for basic permissions you should use:
>>
>> add: user.has_perm('foo.add_bar')
>> change: user.has_perm('foo.change_bar')
>> delete: user.has_perm('foo.delete_bar')
>>
>> How can I show the model Bar in the admin index list without explicitly
>> assigning foo.change_bar or foo.add_bar to the user?
>>
>>
>> You can’t. The admin interface of Django assumes that when a user has
>> access to the administrative interface of an App-Model it’s not to act as a
>> mere passive consumer with read-only access but rather as an active admin
>> over the content (add, change, delete). An administrator who does only
>> inspect or supervise the content doesn’t fit in the sort of administrator
>> that the Django administration app allows. It’s like allowing an
>> administrator who actually does not administer.
>>
>> So far I tried the following, expecting the Bar model to appear in the
>> index list page, but it didn't work.
>>
>> class BarAdmin(admin.ModelAdmin):
>> def get_queryset(self, request):
>> qs = super(BarAdmin, self).get_queryset(request)
>> if request.user.is_superuser:
>> return qs
>> return qs.filter(owner=request.user)
>>
>> def has_add_permission(self, request):
>> return True
>>
>> def has_change_permission(self, request, obj=None):
>> if obj is None:
>> return True
>> if obj.owner == request.user:
>> return True
>> return False
>>
>> def has_delete_permission(self, request, obj=None):
>> i

How to trace a vanished page?

2014-10-07 Thread Helgi Örn Helgason
Hi!
I am quite new when it comes to Django and Python. I am now responsible for 
a rather disfunctional Django website package which is quite messy, to say 
the least (I have this confirmed by an experienced Django/Pyton developer). 
The system is in use serving a school organisation.

My most acute problem right now is to find a way trace why a page on our 
web suddenly quit showing up, going to the url just loads for a while and 
then stops with nothing showing up. The page was working perfectly before 
we did a supervisorctl restart after a power failure, and it's still 
showing in Django admin. The rest of the web is working properly.

My question is; what can I do to find out what's causing this? How can I 
trace like this one in a Django system?

The system is Django 1.3, Python 2.7.3, PostgreSQL, Nginx.

-- 
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/70daec0e-e1e7-4a8d-88bf-932f0c8246f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How do I create a simple user view web page to create/add mysql db entries?

2014-10-07 Thread Bovine Devine
I have gone through the django tutorial but seem to be lost on how to 
create a simple user view page that allows me to add/post/create data 
directly to the connected mysql database. I have the models view working 
and can access and add items in admin view but not sure how/what is the 
best way or method to have an external user view only webpage to create/add 
entries. I was searching in the django 
documentation https://docs.djangoproject.com/en/1.7/topics/db/queries/ but 
it seems to have examples on how to create/add entries from python command 
line.

Any examples of this type of form would be greatly appreciated. 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/bff4c358-db23-432a-b06a-bef88270bae1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Lazy relation not resolved when get_defaults get called

2014-10-07 Thread Ghislain Leveque
I'm in a situation where the get_defaults method on the RelatedField class 
is called but self.rel.to as not been resolved yet and is still a string. 
I'm using Django 1.6.6 and I cannot upgrade easily (big number of systems 
in production).

Some important stuff :

- the problem appears when I create a new object inside a py.test fixture
- if I create the same object inside the shell_plus I have no problem

Here is an extract of my model (foreigns A and B are mandatory, C is not) :


class MyModel(models.Model):

fielda = models.ForeignKey(
'otherapp.modela', db_column='fielda')
fieldb = models.ForeignKey(
'otherapp.modelb', db_column='fieldb')
fieldc = models.ForeignKey(
'otherapp.modelc', db_column='fieldc',
null=True, blank=True)


and here is how I use it :


# A is an instance of otherapp.modela
# B is an instance of otherapp.modelb
my_object = MyModel(fielda=A, fieldb=B)




Is there anything more I can provide to help ?

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/92a3a1aa-0e31-4293-a578-d549fa3c9f37%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to trace a page not showing up?

2014-10-07 Thread Helgi Örn Helgason
Hi!
I am quite new when it comes to Django and Python. I am responsible for a 
rather disfunctional Django website package which is rather messy (I have 
this confirmed by an experienced Django/Pyton developer who took a look at 
it). The system is in use serving a school organisation.

My most acute problem right now is to find a way to trace why a page on our 
web suddenly quit showing up, going to the url just loads for a while and 
then stops with nothing showing up, just blank white. 
This page was working perfectly before we did a supervisorctl restart after 
a power failure, and it is still visible in Django admin. 
The rest of the web is working properly.

What can I possibly do to find out what's causing this? How can I trace 
errors like this one in a Django system?

The system is Django 1.3, Python 2.7.3, PostgreSQL, Nginx.

-- 
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/99f2b771-4474-455a-b090-84991ee8ea6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to trace a page not showing up?

2014-10-07 Thread Erik Cederstrand
Den 07/10/2014 kl. 12.57 skrev Helgi Örn Helgason :

> Hi!
> I am quite new when it comes to Django and Python. I am responsible for a 
> rather disfunctional Django website package which is rather messy (I have 
> this confirmed by an experienced Django/Pyton developer who took a look at 
> it). The system is in use serving a school organisation.
> 
> My most acute problem right now is to find a way to trace why a page on our 
> web suddenly quit showing up, going to the url just loads for a while and 
> then stops with nothing showing up, just blank white. 
> This page was working perfectly before we did a supervisorctl restart after a 
> power failure, and it is still visible in Django admin. 
> The rest of the web is working properly.
> 
> What can I possibly do to find out what's causing this? How can I trace 
> errors like this one in a Django system?

The simplest solution is to insert a breakpoint 
(https://docs.python.org/2/library/pdb.html) at the beginning of your view, 
start the development server and load the problematic URL in a browser. Then go 
to the terminal and single-step through your view to find out where it's 
stalling.

If you page uses javascript, it's possible that Django loads the page correctly 
and the problem lies in your javascript code instead.

Erik

-- 
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/A4E7C87B-19FA-49B9-AF0D-28341E8A6368%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.


django-admin2 into production environment

2014-10-07 Thread Fabio C. Barrionuevo da Luz
hello, I wonder if anyone successfully uses the django-admin2[1] in the
production environment

If so, what are your thoughts on the pros and cons based on your experience
of use.

You have a site or blog which records the problems and solutions
encountered when using and customize django-admin2

Your use case would be very useful for me.


[1] https://github.com/pydanny/django-admin2


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

http://pythonclub.com.br/

Blog colaborativo sobre Python e tecnologias Relacionadas, mantido
totalmente no https://github.com/pythonclub/pythonclub.github.io .

Todos são livres para publicar. É só fazer fork, escrever sua postagem e
mandar o pull-request. Leia mais sobre como publicar em README.md e
contributing.md.
Regra básica de postagem:
"Você" acha interessante? É útil para "você"? Pode ser utilizado com Python
ou é útil para quem usa Python? Está esperando o que? Publica logo, que
estou louco para ler...

-- 
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/CAPVjvMZ0f2iSVrFN9-X%3D1sb1pKdw%2Bzpq2TGVN%3D5HOwK-2yH%2B5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Full text search available on PostgreSQL?

2014-10-07 Thread Benjamin Scherrey
Did you find a solution that worked with ModelAdmin.search_fields &
Postgres? I'm running into the same question.

thanx,

  -- Ben

On Sat, Jun 28, 2014 at 11:15 PM, Bastian Kuberek 
wrote:

> Hi,
>
> Just saw that django.contrib.admin.ModelAdmin.search_fields
> 
>  full
> text search only support MySQL.
>
> Are there plans on any progress towards getting this functionality on
> PostgreSQL?
>
> 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/f0071b4f-a368-4512-a6f7-79d921e32141%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Chief Systems Architect Proteus Technologies 
Chief Fan Biggest Fan Productions 
Personal blog where I am not your demographic
.

This email intended solely for those who have received it. If you have
received this email by accident - well lucky 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/CAHN%3D9D7g09po2usFO7G0RAKD3nYmTdO%2B9B3xNuc6X_bfjeJZMQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Best way to change Site.__str__ to return name not domain

2014-10-07 Thread Michael Jones
Hi,

I am using the sites framework and finding it very useful but I would 
prefer the Site.__str__ method to return the site name instead of the 
domain. What is the best way of going about that? Is it reasonable to 
monkey patch it or do I need to make my own sites app with a copy of the 
code?

It is for situations that I don't control like the admin interface and 3rd 
party apps displaying the Site objects.

Any help would be much appreciated,
Michael

-- 
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/0e6ad3d1-bc34-4724-80a7-e8879fd80c3e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


поиск

2014-10-07 Thread RSS
направьте, пожалуйста
есть форма:
1. первый выпадающий список, одна запись которой равна одной модели
2. в зависимости от выбранной модели, остальные поля принадлежат одной 
модели

если можно ссылки или примеры

-- 
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/61c235b3-720d-477f-af0b-c6af63f27051%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: поиск

2014-10-07 Thread Sergiy Khohlov
Check this one.
http://stackoverflow.com/questions/23304821/django-ajax-populate-form-with-model-data
 also could you please use English in this list ?

Many thanks,

Serge


+380 636150445
skype: skhohlov

2014-10-07 17:58 GMT+03:00 RSS :

> направьте, пожалуйста
> есть форма:
> 1. первый выпадающий список, одна запись которой равна одной модели
> 2. в зависимости от выбранной модели, остальные поля принадлежат одной
> модели
>
> если можно ссылки или примеры
>
> --
> 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/61c235b3-720d-477f-af0b-c6af63f27051%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/CADTRxJN8Sr9%2BaOkK_yCNn27kOnoG-J14bLFEyTMF-jXkoQUVgA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I create a simple user view web page to create/add mysql db entries?

2014-10-07 Thread Collin Anderson
Using a plan ModelForm in a few to create objects is surprisingly not well 
documented :)
https://docs.djangoproject.com/en/1.7/topics/forms/modelforms/

Basically you do something like this:

from django import forms

class MyForm(forms.ModelForm):
class Meta:
model = MyModel
fields = ['field1', 'field2']

@login_required  # if you need it
def add_view(request):
form = MyForm()
if request.method == 'POST':
form = MyForm(request.POST)
if form.is_valid():
the_new_entry = form.save()
return redirect()  # wherever you want to go next
return render(request, 'add_template', {'form': form})


-- 
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/61fb9b6d-fe6c-4501-b562-b8805efd838b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Lazy relation not resolved when get_defaults get called

2014-10-07 Thread Collin Anderson
I use this to fix that problem. Run it before you use your first model.

from django import models
models.get_models()

-- 
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/7d07cea3-5b2d-4e49-aadf-fb1f3fdcd653%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django UserAdmin

2014-10-07 Thread Collin Anderson
Would something like this work?

class UserAdmin(admin.ModelAdmin):
list_display = ('email', 'first_name', 'last_name','is_staff', 
'phone_no')

def phone_no(self, user):
return user.smsregistration.phone_no


-- 
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/276d8c9a-d502-489e-b205-4d4a50979fd6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to trace a page not showing up?

2014-10-07 Thread Collin Anderson
Or raise an exception or use print statements.

It could also be that nginx is timing out, but usually it will say that. 
You could open up the development tools (right click, inspect element) and 
see what error code the network tab says.

-- 
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/a2af2ce1-bba5-40d6-bc47-0758f3ccfb47%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: AppConfig where to execute initialization queries?

2014-10-07 Thread Collin Anderson
Could you somehow lazy initialize? Somehow auto-initialize things the first 
time they are called for?

The other, kind of hacky place to do it is at the top of your urls.py, 
which should run on the first 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+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/3ced8c12-9025-4ebe-9d49-61c9f5e2f998%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


View didn't return an HttpResponse object

2014-10-07 Thread Dariusz Mysior
I have form to change password like below, and when I try to display it I 
have an bug:

ValueError at /password_change/
  

The view dom.views.password_change_dom didn't return an HttpResponse object.


  


  
  


  
  



  
  



   
  Request Method:GETRequest URL:
http://darmys.pythonanywhere.com/password_change/Django Version:1.6.5Exception 
Type:ValueErrorException Value:

The view dom.views.password_change_dom didn't return an HttpResponse object.


My forms.py is:
class FormularzPasswordChange(forms.Form):
password1 = forms.CharField(label="Hasło:",widget=forms.PasswordInput())
password2 = forms.CharField(label="Powtórz hasło:",widget=forms.
PasswordInput())

def clean_password2(self):
password1 = self.cleaned_data['password1']
password2 = self.cleaned_data['password2']
if password1 == password2:
return password2
else:
raise forms.ValidationError("Hasła się różnią")



urls.py

url(r'^password_change/$', views.password_change_dom, name='change_password'
)

change_password.html

{% extends "base_site_dom.html" %}

{% block title %} - zmiana hasła {% endblock %}

{% block content %}


Zmiana hasła na nowe.
Wpisz nowe hasło 2 razy.



{% csrf_token %}
{{ form.as_p }}
 




{% endblock %}
{% block footer %}

Strona głóna

{% endblock %}


-- 
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/5535160a-444c-4ab9-a3bf-1898bf76f188%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


prepopulated_fields is not changed only after user typed text there

2014-10-07 Thread Vitaly
Hi all

Does anybody know the reason why in django1.7 prepopulated fields is not 
changed only after user typed text there? Is that bug or what?

For example


class Post(models.Model):

title = models.CharField('Title', max_length=128)
url = models.SlugField('Url')

class PostAdmin(admin.ModelAdmin):

prepopulated_fields = {"url": ("title",)}


When editing existing Post if user clicks on Title field then Url is 
overrided by value from Title. In django 1.6 url is not changed if user 
changes Title. That's why I think it is regression django bug.

-- 
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/b8817c82-85b5-4f24-b8b6-84b9a666fc94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to implement chained/related dropdown lists in a page

2014-10-07 Thread Frankline
I am interested in knowing how other developers implement chained dropdown
lists that are dependent on one another. As an example, I have a page/form
that has two dropdown lists. When I select a value from the first select, I
want the second dropdown to be populated by records related to the first
one. This is more of a Country/City situation. Below is how my models look
like.

#models.py
class Category(models.Model):
description = models.CharField(max_length=100)

class SubCategory(models.Model):
description = models.CharField(max_length=100)
category = models.ForeignKey(Category)

I am guessing I will have to involve ajax in one way or the other. Anyone
has an idea on how to implement 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEAUGdVbxWnRRf%2BPuvzNDNei0yinKL__9f_DWekprM_9HRSMfA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: View didn't return an HttpResponse object

2014-10-07 Thread Collin Anderson
What does your password_change_dom view look like?

-- 
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/9648a050-dc2e-4339-89c3-980c3fc002fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: View didn't return an HttpResponse object

2014-10-07 Thread Dariusz Mysior
It's :

ef password_change_dom(request):
if request.method == 'POST':
form = FormularzPasswordChange(request.POST)
if form.is_valid():
user = authenticate(username=form.cleaned_data['username'])
 #user = User.objects.get(username='username')
user.set_password(form.cleaned_data['password2']),
user.save()
login(request,user)
template = loader.get_template(
"registration/change_password.html")
variables = RequestContext(request,{'user':user})
output = template.render(variables)
return HttpResponseRedirect("/")
else:
form = FormularzPasswordChange()
template = loader.get_template(
'registration/change_password.html')
variables = RequestContext(request,{'form':form})
output = template.render(variables)
return HttpResponse(output)



W dniu wtorek, 7 października 2014 21:07:35 UTC+2 użytkownik Collin 
Anderson napisał:
>
> What does your password_change_dom view look like?
>

-- 
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/12b78cb0-7c22-41bf-97ef-eac2bbf82fd6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: prepopulated_fields is not changed only after user typed text there

2014-10-07 Thread Collin Anderson
It looks like it's supposed to only change the slug if the slug was blank 
when the page loaded.

https://code.djangoproject.com/ticket/19082

-- 
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/540b996b-a41f-48ea-82c8-49f38640306c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: View didn't return an HttpResponse object

2014-10-07 Thread Collin Anderson
unindent the last bit:
 

> if request.method == 'POST':
> form = FormularzPasswordChange(request.POST)
> if form.is_valid():
> user = authenticate(username=form.cleaned_data['username'
> ])
>  #user = User.objects.get(username='username')
> user.set_password(form.cleaned_data['password2']),
> user.save()
> login(request,user)
> template = loader.get_template(
> "registration/change_password.html")
> variables = RequestContext(request,{'user':user})
> output = template.render(variables)
> return HttpResponseRedirect("/")
> else:
> form = FormularzPasswordChange()
> template = loader.get_template('registration/change_password.html'
> )
> variables = RequestContext(request,{'form':form})
> output = template.render(variables)
> return HttpResponse(output)
>

-- 
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/1ba3687d-286f-4c58-a3c2-fe2eb4fc2d8e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: View didn't return an HttpResponse object

2014-10-07 Thread Collin Anderson
also, I highly recommend the render() shortcut:

def password_change_dom(request):
if request.method == 'POST':
form = FormularzPasswordChange(request.POST)
if form.is_valid():
user = authenticate(username=form.cleaned_data['username'])
user.set_password(form.cleaned_data['password2'])
user.save()
login(request, user)
return HttpResponseRedirect("/")
else:
form = FormularzPasswordChange()
return render(request, 'registration/change_password.html', {'form': 
form})

-- 
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/034d9180-b8c3-4fd1-8d37-9c0cf83c5280%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: View didn't return an HttpResponse object

2014-10-07 Thread Dariusz Mysior
It was like You said, now I see form and when I write password and submit I 
have 

KeyError at /password_change/
  

'username'


  


  
  


  
  



  
  



  
  




  
  




  
  Request Method:POSTRequest URL:http:
//darmys.pythonanywhere.com/password_change/Django Version:1.6.5Exception 
Type:KeyErrorException Value:

'username'

Exception Location:/home/darmys/dom/dom/views.py in password_change_dom, 
line 55



W dniu wtorek, 7 października 2014 21:21:16 UTC+2 użytkownik Collin 
Anderson napisał:
>
> also, I highly recommend the render() shortcut:
>
> def password_change_dom(request):
> if request.method == 'POST':
> form = FormularzPasswordChange(request.POST)
> if form.is_valid():
> user = authenticate(username=form.cleaned_data['username'])
> user.set_password(form.cleaned_data['password2'])
> user.save()
> login(request, user)
> return HttpResponseRedirect("/")
> else:
> form = FormularzPasswordChange()
> return render(request, 'registration/change_password.html', {'form': 
> form})
>
>

-- 
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/7a5e519f-61f2-49c3-83e8-fdc2a3c663dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: View didn't return an HttpResponse object

2014-10-07 Thread Collin Anderson
are they already logged in? use request.user.set_password() and 
request.user.save()

-- 
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/8b5c498c-03f7-446f-80b0-1483bd0a6b1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: View didn't return an HttpResponse object

2014-10-07 Thread Dariusz Mysior
It work's! :)

Thank You!!

 now I have:

def password_change_dom(request):
if request.method == 'POST':
form = FormularzPasswordChange(request.POST)
if form.is_valid():
request.user.set_password(form.cleaned_data['password2'])
request.user.save()
template = loader.get_template(
"registration/change_password.html")
variables = RequestContext(request,{'user':request.user})
output = template.render(variables)
return HttpResponseRedirect("/")
else:
form = FormularzPasswordChange()
return render(request, 'registration/change_password.html', 
{'form': form})



W dniu wtorek, 7 października 2014 20:37:49 UTC+2 użytkownik Dariusz Mysior 
napisał:
>
> I have form to change password like below, and when I try to display it I 
> have an bug:
>
> ValueError at /password_change/
>   
>
> The view dom.views.password_change_dom didn't return an HttpResponse object.
>
>
>   
>
> 
>   
>   
> 
> 
>   
>   
> 
>
> 
>   
>   
> 
>
> 
>
>   Request Method:GETRequest URL:
> http://darmys.pythonanywhere.com/password_change/Django 
> Version:1.6.5Exception 
> Type:ValueErrorException Value:
>
> The view dom.views.password_change_dom didn't return an HttpResponse object.
>
>
> My forms.py is:
> class FormularzPasswordChange(forms.Form):
> password1 = forms.CharField(label="Hasło:",widget=forms.PasswordInput
> ())
> password2 = forms.CharField(label="Powtórz hasło:",widget=forms.
> PasswordInput())
>
> def clean_password2(self):
> password1 = self.cleaned_data['password1']
> password2 = self.cleaned_data['password2']
> if password1 == password2:
> return password2
> else:
> raise forms.ValidationError("Hasła się różnią")
>
>
>
> urls.py
>
> url(r'^password_change/$', views.password_change_dom, name=
> 'change_password')
>
> change_password.html
>
> {% extends "base_site_dom.html" %}
>
> {% block title %} - zmiana hasła {% endblock %}
>
> {% block content %}
>
> 
> Zmiana hasła na nowe.
> Wpisz nowe hasło 2 razy.
> 
> 
> 
> {% csrf_token %}
> {{ form.as_p }}
>   value="Wartoci początkowe">
> 
> 
> 
> 
> {% endblock %}
> {% block footer %}
> 
> Strona głóna
> 
> {% endblock %}
>
>
>

-- 
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/596fb0ed-e644-4911-afdb-9f42a9061e47%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I create a simple user view web page to create/add mysql db entries?

2014-10-07 Thread Bovine Devine
Thanks for the help Collin...I need to read through more of the 
documentation it seems! Going through the chapter am I correct in 
understanding that using ModelForm example you listed as a view does not 
need to be added to urls then? What is the user access page then? Sorry 
this is all really still new to me and I do not understand why they are 
running. I went back to review the forms documentation 
here: https://docs.djangoproject.com/en/1.7/topics/forms/ so is this two 
different ways to do the same thing?

-- 
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/9d830214-bb3d-41d1-be5c-8def1316981b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Advice on template, list of objects from several models

2014-10-07 Thread Anders
Hello,
I am looking for some feedback on a seemingly simple problem.

My advertisement board project have 10+ models, one model per item
category (Cars, Pets, Apartments and so on). The common fields (title,
seller, location etc.) is defined in "MyAbstractModel" and inherited by
all other category models.

So far so good until it comes to rendering the items on the front-page
template.

Right now I just have 10+ blocks with for-loops in the template, listing
the 5 latest items in each category.
But I want to the user to be able to specify the order of categories in
the front page, and also which ones of the categories that should be
shown/hidden.


And that is where I am lost.
I guess I could have a "profile"-model which specifies the order and
visibility for each category, and a decent query filter and order_by
should do the trick I think.

But for the template I do not know, as the properties are different for
each category.
Maybe with a for-tag iterating the object list, and if there is a way to
figure out exactly what type of object it is use some if-tags display
the correct category properties maybe?



Any advice is welcome, and please feel free to ask if it seems unclear
(my thinking sometimes is hard to explain in words).

-A


-- 
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/54341956.90105%40x76.eu.
For more options, visit https://groups.google.com/d/optout.


Is Django an easier solution in order to be able to track click info and establish foreign keys, or can I just use python to complete this task?

2014-10-07 Thread Wadson Espindola
The aim of this exercise is to combine the sample database, click tracking 
information from a test website and application, and information from 
user's social networks.

The sample database contains the following fields and is made up of 500 
records.

first_name, last_name, company_name, address, city, county, 
state, zip, phone1, phone2,   email, web

Here are the instructions:

1) Download the US500 database from 
*http://www.briandunning.com/sample-data/*

2) Use the exchange portion of the telephone numbers (the middle three 
digits) as the proxy for "user clicked on and expressed interest in this 
topic". Identify groups of users that share topic interests (exchange 
numbers match).

3) Provide an API that takes an e-mail address an input, and returns the 
e-mail addresses of other users that share that interest.

4) Extend that API to return users within a certain "distance" N of that 
interest. For example, if the original user has an interest in group 236, 
and N is 2, return all users with interests in 234 through 238.

5) Identify and rank the states with the largest groups, and (separately) 
the largest number of groups.

6) Provide one or more demonstrations that the API works.  These can be via 
a testing framework, and/or a quick and dirty web or command line client, 
or simply by driving it from a browser and  showing a raw result.


I was able to import the data this way, however I know there's a better 
method using the CSV module. The code below just reads lines, I'd like to 
be able to split each individual field into columns and assign primary and 
foreign keys in order to solve the challenge. What's the best method to 
accomplish this task?

import os, csv, json, re

class fetch500(): # 
class instantiation
def __init__(self):   # 
initializes data import object
US_500file = open('us-500.csv')
us_500list = US_500file.readlines()
for column in us_500list:
print column,   # 
prints out phone1 array

data_import = fetch500()
print fetch500() 

-- 
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/1afbcdc3-712a-4c3f-b7e5-968f514d0d4d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


question about userprofile

2014-10-07 Thread Lorenzo Bernardi

Hello,

I'd like to emphasize that it is probably a newbie question but I
don't know what are the keyword I should use for googling. So any
information would be helpful.

I'm trying to add a userprofile to my django app. The idea is to use
a sign-in system so that the user depending on who is can have access to
certain pages.

I think I understand the login part that is I define a user for my app
and make onetoone correspondance with the user table of django. I didn't
implement that yet but I think it should be easy and well documented.
But after that I don't understand how I can use the information in the
user table (like the pages that the user is allowed to enter) in django
and how to set it somewhere. And also since I should change the menu to
reflect that the user can go or not to one page how can I send this info
to the template.

As I said any help is welcome.

sincerely


L.

--
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/543444AE.2050602%40lpn.cnrs.fr.
For more options, visit https://groups.google.com/d/optout.


Re: Is Django an easier solution in order to be able to track click info and establish foreign keys, or can I just use python to complete this task?

2014-10-07 Thread Collin Anderson
I would personally just use plain python for this. It's totally possible to 
group things together using dicts and setdefault(). (Or, since it doesn't 
look like speed is an issue, just loop over the whole file every time you 
need to get info.)

It may be though that you think a lot more in terms of "foreign keys", in 
which case you could create a model for it and then run queries on it. 
Django could also provide you with a "quick and dirty web client" if you 
wanted it.

-- 
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/488d1f93-8bd8-4dcb-a7cc-28378d47c5d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I create a simple user view web page to create/add mysql db entries?

2014-10-07 Thread Collin Anderson
> Am I correct in understanding that using ModelForm example you listed as 
a view does not need to be added to urls then? What is the user access page 
then?
The add_view would need to be added to your urls.

> So is this two different ways to do the same thing?
The main difference is that it's a ModelForm rather than a Form. The Model 
form has a "class Meta" and a form.save() method which automatically 
creates the row in the database for 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/8eb20c11-a771-4789-affa-d30d9a3c59fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: question about userprofile

2014-10-07 Thread Collin Anderson

>
> But after that I don't understand how I can use the information in the 
> user table (like the pages that the user is allowed to enter) in django 
> and how to set it somewhere. And also since I should change the menu to 
> reflect that the user can go or not to one page how can I send this info 
> to the template.

In a view, and in a template you should be able to use something like: 
request.user.userprofile
Basically it's request.user.

As far as permissions go, there's really a lot of ways to do it, but I'll 
mention Django's permission system which might help you:
https://docs.djangoproject.com/en/1.7/topics/auth/default/#permissions-and-authorization
There's @permission_required decorator that you can wrap around your views.
https://docs.djangoproject.com/en/1.7/topics/auth/default/#the-permission-required-decorator
In the templates, the users's permissions are available in {{ perms }}
https://docs.djangoproject.com/en/1.7/topics/auth/default/#permissions


-- 
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/3487a85b-f215-4b32-8125-6db42b8876a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I create a simple user view web page to create/add mysql db entries?

2014-10-07 Thread Bovine Devine


On Tuesday, October 7, 2014 4:49:04 PM UTC-7, Collin Anderson wrote:
>
> > Am I correct in understanding that using ModelForm example you listed as 
> a view does not need to be added to urls then? What is the user access page 
> then?
> The add_view would need to be added to your urls.
>
> I added the add_view to teh urls.py
>

from django.conf.urls import patterns, url

from oneidentry import views

urlpatterns = patterns('',
url(r'^$', views.index, name='index'),
url(r'^$', views.add_view, name='add_view'),

But received an error that the view was not defined. I placed the code 
above into a new forms.py file:

from django import ModelForm
from oneidentry.models import Hardwareid

class HardwareidForm(forms.ModelForm):
 class Meta:
model = Hardwareid
fields = ['hardwareid_text']

def add_view(request):
form = HardwareidForm()
if request.method == 'POST':
form = HardwareidForm(request.POST)
if form.is_valid():
the_new_entry = form.save()
return redirect()  # wherever you want to go next
return render(request, 'base_site.html', {'form': form})

Is that correct? Or does this belong in views.py?

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


Re: How do I create a simple user view web page to create/add mysql db entries?

2014-10-07 Thread Collin Anderson
My bad. Put your add_view in views.py (cause it's a view :)

Then, you'll need to import your form into your view:
from oneidentry.forms import HardwareidForm

-- 
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/5528c00e-8541-4651-b60e-5ce9a168a51c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django admin interface - how to enable adding new entries to foreign key-linked dropdown menu?

2014-10-07 Thread Eliezer Kanal
I'm writing a rudimentary exercise app in django, with the following table 
structure:

Routine Exercise Segment
= = =
routine_name exercise_name routine_id (fk)
routine_id exercise_id exercise_id (fk)
order
duration

* (fk) = foreign key

In practice, this looks as follows:


A Routine contains numerous Segments, and each segment contains one 
Exercise, the order number (where the segment appears in the routine – 
first, second, third, etc), and the duration of that segment.

My question is, is there an way to allow someone to add a new exercise type 
from the "Add routine" view? I.e., if I'm making a new routine, I don't 
necessarily want to have to drop out and go to the Exercise table view to 
add a new exercise to the list. Thanks in advance!

Elli


*Note: This was cross-posted to StackOverflow 
,
 
with very few views there. I thought I'd try here as well.*

-- 
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/4955d625-d898-4fdf-b186-a8db536363b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: cant pass the "CSRF verification failed. Request aborted." error

2014-10-07 Thread dk
I am using 1.7

-- 
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/a5d18554-4e45-4723-a092-55207dd7898b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.