Display Sub-Sub-Menu in Menu Bar

2015-11-18 Thread nAncy sharma
Hi,

I have a designed a structure for my website as :


|-Passenger 
  |-About Us
  |-About1
  |-About2
  |-Contact Us
   
 
But on my website i see the view as:
 |-Passenger 
   |-About Us (dropdown sign)
   |-Contact Us

So here the problem is i can not view or select About1 and About2 :(
Any suggestions?


Thanks in advance!!!


-- 
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/182aa45f-a72f-40b8-a42a-9dfeb41a2a16%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: QuerySet values() or values_list() with some RelatedObjectDoesNotExist records returns only those records with valid related intances

2015-11-18 Thread Steve W
Solved or Work-Around:

#Include a 'select_related()' invocation in the queryset chain, against the 
related model(s):

cases = Case.objects.select_related('release').all()
cases.count()
228

fieldnames = ('reference','release__release')
records = cases.values(*fieldnames)
records.count()
228

#OK, so that is the desired result. I implemented it in my (real) code and 
it works.

#So select_related() appears to be safe with respect to 
RelatedObjectDoesNotExist, returning None as desired, unlike 
queryset.values() which by default seems to remove the record.

#Perhaps a modification of queryset.values() to include the 
select_related() invocation on each related model would return all values 
as expected.

#Somewhere in the django.db.models.query.ValuesQuerySet I would imagine.

thanks.


 

On Thursday, November 19, 2015 at 12:31:44 AM UTC, Steve W wrote:
>
> Condition:  A model with a ForeignKey or OneToOne relationship to another 
> model...
>
 

> ...How then to make queryset.values() or queryset.values_list() behave in 
> the expected manner, by failing gracefully when it finds a member of a 
> queryset to have a RelatedObjectDoesNotExist exception, and thus writing 
> out the record to values() or values_list() the exception notwithstanding.
>
>
>

-- 
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/f443f950-f22d-48a6-be92-67e0bed8c72e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


QuerySet values() or values_list() with some RelatedObjectDoesNotExist records returns only those records with valid related intances

2015-11-18 Thread Steve W
Condition:  A model with a ForeignKey or OneToOne relationship to another 
model, where the related model instance may be null.

Desired Behavior: queryset.values() or values_list() returns all records 
from queryset, not just those with valid related model instance.

Observed Behavior: queryset.values() or values_list() returns records for 
only those members of the queryset where the related model instance exists 

Django 1.8.6 Postgres 9.4.1

#!
class Release(Model):
   release = TextField()

class Case(Model):
reference = TextField()
release = OneToOneField(Release, blank=True, null=True,
..related_name='cases')


from models import Case
cases = Case.objects.all()
cases.count()
228

fieldnames = ['reference']
records = cases.values(*fieldnames)
records.count()
228
#So far, so good

fieldnames = ('reference','release__release')
records = cases.values(*fieldnames)
records.count()
63

#No, not good.  Just lost a whole bunch of records, why?
cases = Case.objects.filter(release__isnull=False)
cases.count()
63
records = cases.values(*fieldnames)
records.count()
63
#Clearly this is because there is no related release for each missing case.

#As we see here:
case_without_release = Case.objects.filter(release__isnull=True)[0]
case.release
ReleatedObjectDoesNotExist: Case has no release

#How then to make queryset.values() or queryset.values_list() behave in the 
expected manner, by failing gracefully when it finds a member of a queryset 
to have a RelatedObjectDoesNotExist exception, and thus writing out the 
record to values() or values_list() the exception notwithstanding.


Thank you,
-Steve 

-- 
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/40691ae2-6b72-48a0-bf4c-e1b10a00a40c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Problem with static folder

2015-11-18 Thread Dariusz Mysior
I had a static folder nr 1 in app accounts and my templates see it, but 
when I create   folder static nr 2 in my project directory tempalates 
dosn't see it. I copy this static folder nr 2 and past to accounts folder 
next to this static folder nr 1 and it is visible. Why in project directory 
this is not visible?

-- 
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/6dbb6bef-d371-48e3-bc76-cfa8663f8fc5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I let forms.models.ModelChoiceField.queryset relate on request.user?

2015-11-18 Thread Axel Rau

> Am 18.11.2015 um 15:28 schrieb 'Tom Evans' via Django users 
> :
> 
> modelform_factory takes many arguments, one of which is for the base
> form class to use. You can provide a different base class from the
> default ModelForm, make sure to derive the new base class from
> ModelForm.
> 
Ah, thanks for the explanation,
Axel
---
PGP-Key:29E99DD6  ☀ +49 160 9945 7889  ☀ computing @ chaos claudius

-- 
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/6458ED0A-FB91-4DA7-BC45-188C5A4CD3E4%40Chaos1.DE.
For more options, visit https://groups.google.com/d/optout.


Re: Making a field readonly according to the user in admin.py

2015-11-18 Thread Mike Dewhirst

These three references should get you started.

get_queryset[1] is useful for filtering the entire display based on the 
request user.


readonly_fields[2] is a simple list of fields which are readonly for 
everyone.


get_readonly_fields[3] is an Admin callable which can be overridden by 
your own method provided your method has the same (request, obj) 
signature. In admin.py you would say get get_readonly_fields = 
my_get_readonly_fields


I agree with Jani that you will be better off in the long run building 
your own interface ... but ymmv


[1] 
https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_queryset


[2] 
https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django.contrib.admin.ModelAdmin.readonly_fields


[3] 
https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_readonly_fields


Mike

On 18/11/2015 9:15 PM, Victor wrote:

Dear experts,

models.py

class Book(models.Model):
 title = models.CharField(max_length=100)
 author = models.CharField(max_length=100)
 quantity = models.IntegerField(db_column='quantitity',default=0)
 class Meta:
 db_table="book"

admin.py

class BookOption(admin.ModelAdmin):
 list_display = ('title', 'author', 'quantity')
 fields=(('title', 'author'), ('quantity'))
 order_by= ['title', ]

admin.site.register(Book,BookOption)


I'm trying to explain my problem with the simple example above.
Let's suppose that I have two staff users 'victor' and 'roby' and I want that 
the fields 'author and 'quantity' be readonly when user 'roby' is logged in and 
readwrite for user 'victor'
How can I achieve this result if possible with something of the following 
simple kind


class BookOption(admin.ModelAdmin):
 if (user is 'roby'):
readonly_fields=['quantity',]
 list_display = ('title', 'author', 'quantity')
 fields=(('title', 'author'), ('quantity'))
 order_by= ['title', ]

Thanks
Vittorio



--
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/564CD7CD.1040707%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: Form/widget Media urls not using the hashed names from ManifestStaticStorage?

2015-11-18 Thread Tim Graham
There's a ticket about it: https://code.djangoproject.com/ticket/21221

I think it's likely to be fixed in Django 1.10. In the meantime, you have 
to wrap the Media urls with 
django.contrib.staticfiles.templatetags.staticfiles.static.

On Wednesday, November 18, 2015 at 12:51:28 PM UTC-5, Bart van der Schoor 
wrote:
>
> I'm trying to upgrade an existing application to use a Manifest based 
> StaticStorage so we can leverage long-term caching.
>
> It works as expected for files included with the `static from staticfiles` 
> template tag: my app shows the hashed names for the standard admin 
> javascript/css files and they all resolve correctly.
>
> But for (admin) widgets that add extra media files using the Media class 
>  I still get 
> the plain (non-hash) filenames in my HTML.
>
> I tried this with both the bundled ManifestStaticStorage as well as 
> ManifestStaticS3Storage from django-s3-storage. 
> 
>
> Curiously the URLs are formed differently: for example: the ones from the 
> template tags have different URLS then the ones from Media classes:
>
> https://s3-eu-west-1.amazonaws.com:443/my-project/static/admin/js/actions.min.2893760b9e40.js
> ">
> https://s3-eu-west-1.amazonaws.com/my-project/static/js/my_custom_scipt.js
> ">
>
> The second one corresponds with what I have set as STATIC_URL, while to 
> first one seems to be generated by the S3 storage (it has an explicit port 
> number). I see these non-transformed URLs for all media attached by myself 
> or third-party widgets.
>
>
> Next I looked into the source on Github, and this confirms my fear that 
> form-media urls are simply joined to the STATIC_URL instead of passed 
> through the staticfiles manifest mechanism.
>
> For example: 
> https://github.com/django/django/blob/f59a0401e5d0e19568a038f2a50954d1a9a1526f/django/forms/widgets.py#L80-L85
>
>
> Doesn't this kinda defeats the purpose of using the staticfiles app and 
> Manifest Storage if a fair part of our static files are not processed by 
> it? Or do I miss some override or setting?
>
> All this was using Django 1.8.6 with Python 3.4 on Ubuntu.
>
>
> Any ideas what is intended here?
>
>
> Bart
>

-- 
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/cb8577b1-5214-4a13-9977-1c8a81e56954%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Requesting data from an API and rendering data on website

2015-11-18 Thread Adam Simon


With all respect Jani, I do not think this is the right answer. Django-cms 
per se does not give top level access to the views, so integrating pure 
python is not as easy as it sounds.  Adam


On Wednesday, November 18, 2015 at 3:50:46 AM UTC-8, Jani Tiainen wrote:
>
> Then I suggest that you do official tutorial from Django documentation.
>
> It will give you a grasp what Django itself is and how it works. Django 
> CMS is just built on top of Django so principles do apply there as well.
>
> On 18.11.2015 13:14, nAncy sharma wrote:
>
> Hi Avraham,
>
> Yes that should work.
> But since i am new to django cms , i don't know the files (ex: model.py 
> ,view.py etc ) which all files need changes and where does the actual code 
> of requesting to an API is to be written.
>
>
>
>
> On Wednesday, November 18, 2015 at 4:26:16 PM UTC+5:30, Avraham Serour 
> wrote: 
>>
>> Can you do it in plain python?
>>
>> On Wed, Nov 18, 2015, 12:34 PM nAncy sharma  wrote:
>>
>>> Hi, 
>>>
>>>
>>> I am using Django Cms 3.1.3. I want to give a call (request ) to an API 
>>> and display the result on my website. 
>>> Could anyone help me with this ? I am new to django cms !
>>> -- 
>>> 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.
>>> To view this discussion on the web visit 
>>> 
>>> https://groups.google.com/d/
>>> msgid/django-users/85c04d98-8cbe-414b-808a-6ff1dede2442%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...@googlegroups.com .
> To post to this group, send email to django...@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/7dc809a0-4f20-4cd6-99b8-d50e3e186285%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> -- 
>
> Jani Tiainen
>

-- 
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/83c6cf6f-5b55-43c0-91a7-d09818d197d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Form/widget Media urls not using the hashed names from ManifestStaticStorage?

2015-11-18 Thread Bart van der Schoor
I'm trying to upgrade an existing application to use a Manifest based 
StaticStorage so we can leverage long-term caching.

It works as expected for files included with the `static from staticfiles` 
template tag: my app shows the hashed names for the standard admin 
javascript/css files and they all resolve correctly.

But for (admin) widgets that add extra media files using the Media class 
 I still get the 
plain (non-hash) filenames in my HTML.

I tried this with both the bundled ManifestStaticStorage as well as 
ManifestStaticS3Storage from django-s3-storage. 


Curiously the URLs are formed differently: for example: the ones from the 
template tags have different URLS then the ones from Media classes:

https://s3-eu-west-1.amazonaws.com:443/my-project/static/admin/js/actions.min.2893760b9e40.js";>
https://s3-eu-west-1.amazonaws.com/my-project/static/js/my_custom_scipt.js";>

The second one corresponds with what I have set as STATIC_URL, while to 
first one seems to be generated by the S3 storage (it has an explicit port 
number). I see these non-transformed URLs for all media attached by myself 
or third-party widgets.


Next I looked into the source on Github, and this confirms my fear that 
form-media urls are simply joined to the STATIC_URL instead of passed 
through the staticfiles manifest mechanism.

For example: 
https://github.com/django/django/blob/f59a0401e5d0e19568a038f2a50954d1a9a1526f/django/forms/widgets.py#L80-L85


Doesn't this kinda defeats the purpose of using the staticfiles app and 
Manifest Storage if a fair part of our static files are not processed by 
it? Or do I miss some override or setting?

All this was using Django 1.8.6 with Python 3.4 on Ubuntu.


Any ideas what is intended here?


Bart

-- 
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/a25d23df-5012-4054-b991-68114713a5f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(secure-auth) very old mysql. old django, up-to-date workstation

2015-11-18 Thread 술욱
Hello,

mysql server 3
django 1.6.11
workstation: ubuntu wily (15.10) mysql client 5.6.27


I need to make Django recognize secure-auth=false or skip-secure-auth=true
but so far I couldn't


I tried in project/settings.py

'OPTIONS': {
'skip-secure-auth': 'true',
},

'OPTIONS': {
'secure-auth': 'false',
},

and combinations of '-' and '_', and False, FALSE, false (same for true).


Also tried:

'OPTIONS': {
'read_default_file': os.path.join(BASE_DIR, 'conf/my.cnf'),
}

And in conf/my.cnf:

[client] (and mysql)

skip-secure-auth (and its variations)


None works.

Then I tried skip-secure-auth in /etc/mysql/my.cnf [mysql] and this works
in the cli, but Django seems to ignore this file.


Does anybody have other ideas?

Thanks!
Norberto

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


Re: Getting NoReverseMatch and can't find the mistake

2015-11-18 Thread 'Tom Evans' via Django users
On Tue, Nov 17, 2015 at 7:08 PM, Bob Aalsma  wrote:
> Sorry, can't seem to find what's wrong here, please help: what am I
> missing???
>
> I'm seeing
>
> NoReverseMatch at /zoekopdrachten/4/resultaat/
>
> Reverse for 'resultaat' with arguments '('',)' and keyword arguments '{}'
> not found. 1 pattern(s) tried:
> [u'zoekopdrachten/(?P[0-9]+)/resultaat/$']

The pattern asked for an argument, but no arguments were passed to
reverse() / {% url %}

> 
> and vraag.html:
> Zoekvraag "{{ vraag.zoekvraag_id }}"
>
> {% if error_message %}
> {{ error_message }}
> 
> {% endif %}
>
> Verzamelen resultaten
>  method="post">

and therefore the argument you are trying to pass here does not exist.
Debug your template context to determine why.

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1JTfWteyz%3DXVCLzmstSGL9XHzsuqnCpBu1soW1uYcO4PQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I let forms.models.ModelChoiceField.queryset relate on request.user?

2015-11-18 Thread 'Tom Evans' via Django users
On Mon, Nov 16, 2015 at 5:38 PM, Axel Rau  wrote:
>
> Any idea how to add __init__() to a form class, created by modelform_factory 
> () ?
>
> Axel
>

modelform_factory takes many arguments, one of which is for the base
form class to use. You can provide a different base class from the
default ModelForm, make sure to derive the new base class from
ModelForm.

https://docs.djangoproject.com/en/1.8/ref/forms/models/#django.forms.models.modelform_factory

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1LCk_oH4HLMW_7KhjtARkZxESxgQGBUrCeHx1D24h%3DpdQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Timer for online examination

2015-11-18 Thread bobhaugen
That should have been runTimer and retryTimer

On Tuesday, November 17, 2015 at 7:43:02 AM UTC-6, bobhaugen wrote:
>
> On Tuesday, November 17, 2015 at 12:29:02 AM UTC-6, Arindam sarkar wrote:
>>
>> I am developing an online examination website. And having difficulty 
>> implementing the timer .
>> Any one have done it or something related to countdown timer in django ?
>>
>>
> Here is an example of what everybody is telling you to do in javascript:
>
> https://github.com/valnet/valuenetwork/blob/master/valuenetwork/templates/valueaccounting/work_now.html
>  
> 
>
> Look for runTime and retryTimer 
>

-- 
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/d3898c3a-1031-45ab-a8a2-d5eda89f39bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Making a field readonly according to the user in admin.py

2015-11-18 Thread Timothy W. Cook
While Jani's admonishments might be considered 'best practice' in some
cases. Those do not always cover everyone's use case.

I solved a similar issue allowing users with the superuser role to have
edit access to some items that other staff do not have access to edit.

Use the get_form method of the ModelAdmin and select the form to call.

For example:
def get_form(self, request, obj=None, **kwargs):
if request.user.is_superuser:
kwargs['form'] = DMAdminSUForm
else:
kwargs['form'] = DMAdminForm

Then in each form you can set the readonly attributes and any other user
role specific functionality you need.

HTH,
Tim







On Wed, Nov 18, 2015 at 8:21 AM, Jani Tiainen  wrote:

> Hi,
>
> In general you shouldn't be even trying to do this in admin since it's not
> designed for this kind of functionality.
>
> Admin is just a datacentric tool to view your data. It's never been meant
> to help implementing any businesslogic. And basically you only should let
> people in admin that you trust full 100%.
>
> If you can't trust them (which is indicated by "readonly field"
> requirement) you should do custom view and templates for that. Generic
> class based views can greatly help you to achieve it, and most probably
> with really less effort than trying to do that in admin.
>
>
>
> On 18.11.2015 12:15, Victor wrote:
>
>> Dear experts,
>>
>> models.py
>>
>> class Book(models.Model):
>>  title = models.CharField(max_length=100)
>>  author = models.CharField(max_length=100)
>>  quantity = models.IntegerField(db_column='quantitity',default=0)
>>  class Meta:
>>  db_table="book"
>>
>> admin.py
>>
>> class BookOption(admin.ModelAdmin):
>>  list_display = ('title', 'author', 'quantity')
>>  fields=(('title', 'author'), ('quantity'))
>>  order_by= ['title', ]
>>
>> admin.site.register(Book,BookOption)
>>
>>
>> I'm trying to explain my problem with the simple example above.
>> Let's suppose that I have two staff users 'victor' and 'roby' and I want
>> that the fields 'author and 'quantity' be readonly when user 'roby' is
>> logged in and readwrite for user 'victor'
>> How can I achieve this result if possible with something of the following
>> simple kind
>>
>>
>> class BookOption(admin.ModelAdmin):
>>  if (user is 'roby'):
>> readonly_fields=['quantity',]
>>  list_display = ('title', 'author', 'quantity')
>>  fields=(('title', 'author'), ('quantity'))
>>  order_by= ['title', ]
>>   Thanks
>> Vittorio
>>
>> --
>
> Jani Tiainen
>
> --
> 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/564C5123.1020501%40gmail.com
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 


Timothy Cook
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
MLHIM http://www.mlhim.org

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


Re: Requesting data from an API and rendering data on website

2015-11-18 Thread Jani Tiainen

Then I suggest that you do official tutorial from Django documentation.

It will give you a grasp what Django itself is and how it works. Django 
CMS is just built on top of Django so principles do apply there as well.


On 18.11.2015 13:14, nAncy sharma wrote:

Hi Avraham,

Yes that should work.
But since i am new to django cms , i don't know the files (ex: 
model.py ,view.py etc ) which all files need changes and where does 
the actual code of requesting to an API is to be written.





On Wednesday, November 18, 2015 at 4:26:16 PM UTC+5:30, Avraham Serour 
wrote:


Can you do it in plain python?


On Wed, Nov 18, 2015, 12:34 PM nAncy sharma  wrote:

Hi,


I am using Django Cms 3.1.3. I want to give a call (request )
to an API and display the result on my website.
Could anyone help me with this ? I am new to django cms !
-- 
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
.
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/85c04d98-8cbe-414b-808a-6ff1dede2442%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/7dc809a0-4f20-4cd6-99b8-d50e3e186285%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--

Jani Tiainen

--
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/564C65F6.3070005%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Requesting data from an API and rendering data on website

2015-11-18 Thread nAncy sharma
Hi Avraham,

Yes that should work.
But since i am new to django cms , i don't know the files (ex: model.py 
,view.py etc ) which all files need changes and where does the actual code 
of requesting to an API is to be written.




On Wednesday, November 18, 2015 at 4:26:16 PM UTC+5:30, Avraham Serour 
wrote:
>
> Can you do it in plain python?
>
> On Wed, Nov 18, 2015, 12:34 PM nAncy sharma  > wrote:
>
>> Hi,
>>
>>
>> I am using Django Cms 3.1.3. I want to give a call (request ) to an API 
>> and display the result on my website. 
>> Could anyone help me with this ? I am new to django cms !
>>
>> -- 
>> 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.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/85c04d98-8cbe-414b-808a-6ff1dede2442%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/7dc809a0-4f20-4cd6-99b8-d50e3e186285%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django model proxy override save

2015-11-18 Thread drifter
I want to override the save for a model when saved from the proxy I've 
tried commenting out as much as I can but it's still using the model save. 
Here's my code.

class MovieProxy(Movie):
class Meta:
verbose_name = 'movie show'
proxy=True

def save(self, *args, **kwargs):
#super(MovieProxy, self).save(*args, **kwargs)
fily = open('post-{0}'.format(self.id),'w')
fily.write(*args)
fily.write('\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n')
fily.write(**kwargs)
fily.close()

-- 
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/da0cdf2f-fab0-4c35-ba7d-1748c4ab48e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Requesting data from an API and rendering data on website

2015-11-18 Thread Avraham Serour
Can you do it in plain python?

On Wed, Nov 18, 2015, 12:34 PM nAncy sharma 
wrote:

> Hi,
>
>
> I am using Django Cms 3.1.3. I want to give a call (request ) to an API
> and display the result on my website.
> Could anyone help me with this ? I am new to django cms !
>
> --
> 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/85c04d98-8cbe-414b-808a-6ff1dede2442%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/CAFWa6tKashvW%2BXS2f52jff0zbp%2B61_G053O8ZUSijczZDftAfg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Requesting data from an API and rendering data on website

2015-11-18 Thread nAncy sharma
Hi,


I am using Django Cms 3.1.3. I want to give a call (request ) to an API and 
display the result on my website. 
Could anyone help me with this ? I am new to django cms !

-- 
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/85c04d98-8cbe-414b-808a-6ff1dede2442%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Making a field readonly according to the user in admin.py

2015-11-18 Thread Jani Tiainen

Hi,

In general you shouldn't be even trying to do this in admin since it's 
not designed for this kind of functionality.


Admin is just a datacentric tool to view your data. It's never been 
meant to help implementing any businesslogic. And basically you only 
should let people in admin that you trust full 100%.


If you can't trust them (which is indicated by "readonly field" 
requirement) you should do custom view and templates for that. Generic 
class based views can greatly help you to achieve it, and most probably 
with really less effort than trying to do that in admin.



On 18.11.2015 12:15, Victor wrote:

Dear experts,

models.py

class Book(models.Model):
 title = models.CharField(max_length=100)
 author = models.CharField(max_length=100)
 quantity = models.IntegerField(db_column='quantitity',default=0)
 class Meta:
 db_table="book"

admin.py

class BookOption(admin.ModelAdmin):
 list_display = ('title', 'author', 'quantity')
 fields=(('title', 'author'), ('quantity'))
 order_by= ['title', ]

admin.site.register(Book,BookOption)


I'm trying to explain my problem with the simple example above.
Let's suppose that I have two staff users 'victor' and 'roby' and I want that 
the fields 'author and 'quantity' be readonly when user 'roby' is logged in and 
readwrite for user 'victor'
How can I achieve this result if possible with something of the following 
simple kind


class BookOption(admin.ModelAdmin):
 if (user is 'roby'):
readonly_fields=['quantity',]
 list_display = ('title', 'author', 'quantity')
 fields=(('title', 'author'), ('quantity'))
 order_by= ['title', ]
  
Thanks

Vittorio


--

Jani Tiainen

--
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/564C5123.1020501%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Making a field readonly according to the user in admin.py

2015-11-18 Thread Victor
Dear experts,

models.py

class Book(models.Model):
title = models.CharField(max_length=100)
author = models.CharField(max_length=100)
quantity = models.IntegerField(db_column='quantitity',default=0)
class Meta:
db_table="book"

admin.py

class BookOption(admin.ModelAdmin):
list_display = ('title', 'author', 'quantity')
fields=(('title', 'author'), ('quantity'))
order_by= ['title', ]

admin.site.register(Book,BookOption)


I'm trying to explain my problem with the simple example above. 
Let's suppose that I have two staff users 'victor' and 'roby' and I want that 
the fields 'author and 'quantity' be readonly when user 'roby' is logged in and 
readwrite for user 'victor'
How can I achieve this result if possible with something of the following 
simple kind


class BookOption(admin.ModelAdmin):
if (user is 'roby'):
readonly_fields=['quantity',]
list_display = ('title', 'author', 'quantity')
fields=(('title', 'author'), ('quantity'))
order_by= ['title', ]
 
Thanks
Vittorio

-- 
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/D0A08E87-6F59-404C-9357-789CC61C4F82%40gmail.com.
For more options, visit https://groups.google.com/d/optout.