Re: Help

2022-09-27 Thread Sonu
You can learn Django.
Click the below link

https://www.youtube.com/c/CodeKeen/playlists

On Tue, 27 Sept 2022 at 01:41, Balogun Awwal 
wrote:

> Hello I just learnt python Iā€™m looking to learn django can you recommend
> some tutorials and it will also be very helpful if I can get a mentor also
> please
>
> Sent from awwal
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CD4750AF-8818-422E-A96C-E193D6E5944A%40gmail.com
> .
>

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


Re: logout_redirect_url not defined

2022-09-22 Thread Sonu
Yeah it will be work.  šŸ˜Š

On Thu, Sep 22, 2022, 8:38 AM Ahmed Abdelmonem 
wrote:

> You should write it this way :  *'/login/'*  in urls.py  should be written*
> path('login/', etc) or index instead in your case.*
>
>
> On Thu, Sep 22, 2022 at 3:32 AM abdallah elassaad <
> elassaadabdal...@gmail.com> wrote:
>
>> can you pls help
>> in my "setting.py"
>> i add this line
>> LOGOUT_REDIRECT_URL ='index'
>>
>> in terminal i receive this message :
>>
>> 'LOGOUT_REDIRECT_URL' is not defined
>>
>> what is missing or how i should define 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/b49c2159-8bfb-4c9e-8491-957824af52edn%40googlegroups.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPV6dzgcFp%3DG0euWKDEZsC%3DQ2M17hBmHrMiTTJdC%3DBKJFPF-mg%40mail.gmail.com
> 
> .
>

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


Re: insert or update on table "app_job" violates foreign key constraint "app_job_user_id_f90a6dd9_fk_accounts_user_id" DETAIL: Key (user_id)=(3) is not present in table "accounts_user".

2019-07-08 Thread Sonu bhavsar
hello please first chak the value which you wants to insert you django
server
didn't get the foreign key which you had diffiend  so this is the value
error according to me

On Mon 8 Jul, 2019, 1:21 AM Aayush Bhattarai, 
wrote:

> [image: Capture.PNG]
>
>
> *I have used a function-based View to get data from post Request. I need
> to get many data that also include a primary key field too. I need to push
> data into two models. While doing so, I encountered an error.*
>
> #accounts models.py
> from django.db import models
> class User(models.Model):
> user_id = models.PositiveIntegerField(blank=True)
>
> name = models.CharField(max_length=200)
> phone = models.CharField(max_length=200)
> email = models.EmailField(max_length=254)
>
> #app models.py
> from accounts.models import User #from accounts models.py
> class job(models.Model):
> user = models.ForeignKey(User, on_delete=models.DO_NOTHING)
> ..
>
> #views.py
> data = job(.,map_link=map_link,user_id=user_id)
> data.save()
> info=User(name=name,email=email,phone=phone,user_id=user_id)
> info.save()
>
> *Error Message: http://dpaste.com/03Z0EPB *
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9f083194-4a44-4f09-94d2-5479fed45ab5%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFYH2d6Z%2BMf9t_Y2rW%3D8koreBymDy7cfSUMrJznJN_%3DRFsA8_A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Add a custom language for internationalization/localization

2016-07-22 Thread Sonu Kumar
After lots of debug and digging inside local middleware I have fixed this. 
To solve this I had to add LOCALE_PATH in settings file.

On Friday, July 22, 2016 at 6:41:44 PM UTC+5:30, Sonu Kumar wrote:
>
> Hi there, 
> I would like to add a custom language to support for i18n. You can check 
>  my question here 
> http://stackoverflow.com/questions/38511925/add-custom-language-for-localization-in-django-app.
>  
> I have followed all the steps mentioned here 
> http://stackoverflow.com/questions/19267886/adding-a-custom-language-to-django
> . 
>
> In short, the steps are as follows
> 1. add a custom language(NEW) dictionary to settings file and update 
> LANG_INFO dictionary 
> 2. add new language to LANGUAGES as well for i18n to detect 
> 3. compile message for the new language 
>
> Problem is that when I visit the home page with new language code then it 
> redirects to /en/NEW
>
> Can somebody point out the error or make it working?
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/62765b9d-8e24-4758-ae11-e8f73b330940%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Add a custom language for internationalization/localization

2016-07-22 Thread Sonu Kumar
Hi there, 
I would like to add a custom language to support for i18n. You can check 
 my question 
here 
http://stackoverflow.com/questions/38511925/add-custom-language-for-localization-in-django-app.
 
I have followed all the steps mentioned 
here 
http://stackoverflow.com/questions/19267886/adding-a-custom-language-to-django. 

In short, the steps are as follows
1. add a custom language(NEW) dictionary to settings file and update 
LANG_INFO dictionary 
2. add new language to LANGUAGES as well for i18n to detect 
3. compile message for the new language 

Problem is that when I visit the home page with new language code then it 
redirects to /en/NEW

Can somebody point out the error or make it working?

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ac797860-0882-4cae-9064-f1e07e60a9c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Implement page view count without using database for Hit

2016-02-08 Thread sonu kumar
Thanks James,
We have consider database and updated sites using django-visits. Building 
such a full proof system will take longer time.

Regars,
Sonu

On Monday, February 8, 2016 at 2:29:46 PM UTC+5:30, James Schneider wrote:
>
>
> On Feb 7, 2016 7:03 PM, "sonu kumar" > 
> wrote:
> >
> > Hi all,
> > We have develop a site where we need to maintain page view count like 
> SO, Quora,YouTube etc. Current approach is based on  number of retrieval 
> using view this leads to problem to user that they are seeing that when a 
> page is reloaded then count get's incremented see here 
> http://www.job360.io/question-answer/cse/how-to-add-two-large-numbers. 
> >
> > How to tackle this problem, is there any exist which can do the work 
> without managing database ?
> >
>
> I'm a bit confused as to why you would be averse to managing a database, 
> assuming that you have an existing database for your users and other 
> content.
>
> If you don't want to manage the page hits yourself, you may look at 
> something like Google Analytics to track it for you.
>
> As far as the refresh question, I haven't researched this in detail, but 
> as far as I'm aware, there is no standard method for requesting refreshes 
> that all browsers follow, and it is difficult to determine whether a 
> request is an initial content load request, or a refresh request without 
> either the browser signaling the server with some type of request header, 
> or some extensive tracking of requests with timers and other heuristics on 
> the server side, and then of course your code has to catch all of those 
> scenarios.
>
> You're trying to merge the concept of a session with a request cycle. 
> Unfortunately, humans think of web access more in terms of sessions, where 
> the HTML, images, stylesheets, authentication, etc. are a single unit 
> carried through while a user browsers a site, but HTTP is built to use a 
> single content request cycle for each resource, independent of any other 
> content request cycle. There are many tricks involved to provide the 
> 'human' experience, like storing/retrieving session data for each HTTP 
> request (which is why your web server process should provide images and 
> stylesheets directly, not Django, so that those tricks are not invoked).
>
> There's no easy answer to your question. It's possible that Analytics our 
> a similar service will perform those database gymnastics for you in their 
> optimized environments to try and remove refreshes from your counts, but 
> you'd have to check with them.
>
> You should also consider the guidelines for what you are counting as a 
> 'hit' for your counter. Perhaps a refresh after 3 seconds shouldn't be 
> counted, but what about a refresh after 45 minutes? What if the same user 
> has multiple browsers open to the same site? What if robot crawlers access 
> your page? Maybe you can filter those out via the reported user agent, but 
> what if they spoof a real browser signature and request 10K hits? What if 
> you have an SPA that polls the server for updates data?
>
> Honestly, unless analytics takes care of this for you, it probably is not 
> worth the extra effort of saving a couple dozen refresh requests. As your 
> page reaches up into tens of thousands of hits, they'll probably become 
> statistically insignificant anyway. 
>
> -James
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/01c4807a-9506-42ad-8ab7-a62a73ea3640%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Implement page view count without using database for Hit

2016-02-07 Thread sonu kumar
Hi all,
We have develop a site where we need to maintain page view count like SO, 
Quora,YouTube etc. Current approach is based on  number of retrieval using 
view this leads to problem to user that they are seeing that when a page is 
reloaded then count get's incremented see here 
http://www.job360.io/question-answer/cse/how-to-add-two-large-numbers. 

How to tackle this problem, is there any exist which can do the work 
without managing database ?

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b5bf873d-9edb-4a20-bd6a-0d27e058aa71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why counter tag is not working as expected in django?

2016-01-21 Thread sonu kumar
No, I am numbering in different ways. each question got different number
event hough it's part of sub question.
Yeah I got working see my gist
https://gist.github.com/sonus21/0ebd1b894ec837c8f8b2

On Fri, Jan 22, 2016 at 4:27 AM, James Schneider 
wrote:

>
>
> On Wed, Jan 20, 2016 at 8:00 PM, sonu kumar  wrote:
>
>> SO link:
>> http://stackoverflow.com/questions/34894964/why-counter-tag-is-not-working-as-expected-in-django
>>
>> I am using two for loop one is for main question and another one is for
>> sub questions.
>>
> Why? We have some comprehension type question, in comprehension type
>> question there could be more than one questions so one outer for loop is
>> running for main question and another one is sub questions.
>>
>
> Right. You would have two {% for %} loops. If you look at the table of
> variables made available for those loops, you can see that you can access
> the counters for both the inner and outer loops separately. No need for an
> external template tag to keep track. If all you are doing is automatically
> numbering questions (and sub-questions with an inner {% for %} loop), then
> the {% for %} loop already provides everything you need.
>
> {% for question in questions %}
> {{ forloop.counter }}: {{ question}}
> {% for sub_question in question.sub_questions %}
> {{ forloop.counter }}: {{ sub_question }}
> {% endfor %}
> {% endfor %}
>
> Would produce something like:
>
> 1: What is your name?
> 1: Is it Frodo?
> 2: Is it Harry Potter?
> 2: What is your quest?
> 1: To be The Doctor?
> 2: To seek out new life and new civilizations?
> 3: To join the dark side?
> 3: What is your favorite color?
> 1: Is it blue?
> 2: Is it yellow?
>
> The only instance where I can see the tag being of use is if you are
> keeping track of a particular type of question that may not match all
> elements in the loop. Then again, you can also work around that with a
> proper data structure being fed to your template, and then use filters like
> |length to figure out how many of each type of question you have.
>
> -James
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/MxHQS3S_u7Y/unsubscribe.
> To unsubscribe from this group and all its topics, 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWvxZS4sTeLbbOqYRuFP3kSzgPiT84%3DatQpq6HH0JCfTw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWvxZS4sTeLbbOqYRuFP3kSzgPiT84%3DatQpq6HH0JCfTw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Regards:
Sonu Kumar

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BcTr%2B0EdxPnh1TTGdtWsyCZJCSdFXmb87%3DRF8SO8%3Dc-5spiow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why counter tag is not working as expected in django?

2016-01-20 Thread sonu kumar
SO link: 
http://stackoverflow.com/questions/34894964/why-counter-tag-is-not-working-as-expected-in-django

I am using two for loop one is for main question and another one is for sub 
questions. 
Why? We have some comprehension type question, in comprehension type 
question there could be more than one questions so one outer for loop is 
running for main question and another one is sub questions.  

On Thursday, January 21, 2016 at 3:33:42 AM UTC+5:30, James Schneider wrote:
>
>
>
> On Wed, Jan 20, 2016 at 6:14 AM, sonu kumar  > wrote:
>
>> https://djangosnippets.org/snippets/2619/
>>
>> According to above snippet if we access {{ counter_var }} in template 
>> after initializing it should return previous count. But in my case it does 
>> not return anything.
>>
>>
>> That snippet is from 2011, and is tagged for Django 1.3. I'd be careful 
> with it. There's been a fair number of changes to template tags between 1.3 
> and 1.8, so I wouldn't be surprised if something is slightly off here.
>  
>
>> template code
>>
>> Q{% counter %}. ...var 
>> no_of_questions={{ counter_var }}
>>
>>
>>
> Have you installed the django-debug-toolbar and inspected the value of the 
> context? It could be that the snippet is no longer updating counter_var in 
> the context correctly. Also make sure that you are using {% counter %} and 
> {{ counter_var }} inside the same set of {% block %} tags, as variable 
> scope does not extend outside of blocks.
>  
>
>> Template tag is registered and it prints correctly Q. except 
>> counter_var. Even I tried by setting context variable counter_var from 
>> view as {'counter_var':0,...} then it returns '0'.
>>
>> How to get it working so that it returns previous counter?
>> e.g.
>>
>> Q1. 
>> Q2.
>>
>> then counter_var should return 2 instead of nothing.
>>
>> Django: 1.8.6
>> Python: 2.7
>>
>
> How exactly are you generating these questions? Is there another context 
> variable that contains the list of questions that you are printing? And if 
> so, are you using a {% for %} loop to generate them? If so, I would 
> recommend you use {{ forloop.counter }} rather than trying to track the 
> counts yourself. See the list of variables available inside of {% for %} 
> loops at the end of this section: 
>
> https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#for
>  
>
>> *Note: I asked same question on stackoverflow but no help till now.*
>>
> A link to the SO question would be helpful if you want help there, or if 
> someone wants reputation points.
>
> -James
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/65753566-d52e-4dcd-ad20-34e01ae45a4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Why counter tag is not working as expected in django?

2016-01-20 Thread sonu kumar


https://djangosnippets.org/snippets/2619/

According to above snippet if we access {{ counter_var }} in template after 
initializing it should return previous count. But in my case it does not 
return anything.


template code

Q{% counter %}. ...var 
no_of_questions={{ counter_var }}


Template tag is registered and it prints correctly Q. except 
counter_var. Even I tried by setting context variable counter_var from view 
as {'counter_var':0,...} then it returns '0'.

How to get it working so that it returns previous counter?
e.g.

Q1. 
Q2.

then counter_var should return 2 instead of nothing.

Django: 1.8.6
Python: 2.7


*Note: I asked same question on stackoverflow but no help till now.*


-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bd6b7357-70af-4a34-b50b-8d5711319e5c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


JSON serializer is not working for subset of fields.

2016-01-05 Thread sonu kumar


Models

class Country(models.Model):
country = CountryField()

class City(models.Model):
name = models.CharField(max_length=1000)
country = models.ForeignKey(Country)



country = request.POST['country']
country = get_object_or_404(Country, country=country)

cities = serializers.serialize("json", country.city_set.all(), fields=('name', 
'id'))


In this it should return JSON object with only name and id field but it returns 
[{"fields": {"name": "Chennai"}, "model": "job.city", "pk": 1}] instead of 
[{"name": "Chennai", "id": 1}]. 


How to fix this error?

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a7c99e04-fa0b-46b3-adec-3f3031b85954%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: JSON serializer is not working for subset of fields.

2016-01-05 Thread sonu kumar


country = request.POST['country']
country = get_object_or_404(Country, country=country)


On Tuesday, January 5, 2016 at 6:02:28 PM UTC+5:30, sonu kumar wrote:
>
> Models
>
> class Country(models.Model):
> country = CountryField()
>
> class City(models.Model):
> name = models.CharField(max_length=1000)
> country = models.ForeignKey(Country)
>
> cities = serializers.serialize("json", country.city_set.all(), 
> fields=('name', 'id'))
>
>
> In this it should return JSON object with only name and id field but it 
> returns [{"fields": {"name": "Chennai"}, "model": "job.city", "pk": 1}] 
> instead of [{"name": "Chennai", "id": 1}]. 
>
>
> How to fix this error?
>
>
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1429ec4c-e3c3-4160-963f-a747d3381909%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


JSON serializer is not working for subset of fields.

2016-01-05 Thread sonu kumar


Models

class Country(models.Model):
country = CountryField()

class City(models.Model):
name = models.CharField(max_length=1000)
country = models.ForeignKey(Country)

cities = serializers.serialize("json", country.city_set.all(), fields=('name', 
'id'))


In this it should return JSON object with only name and id field but it returns 
[{"fields": {"name": "Chennai"}, "model": "job.city", "pk": 1}] instead of 
[{"name": "Chennai", "id": 1}]. 


How to fix this error?



-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5e259ad6-c5bf-42de-9c97-24c921ebdfd4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


JSON serializers not workinf for some of subset of fields.

2016-01-05 Thread sonu kumar


cities = serializers.serialize("json", country.city_set.all(), fields=('name', 
'id'))

In this it should JSON object with only name and id field but it returns 
[{"fields": {"name": "Chennai"}, "model": "job.city", "pk": 1}] where as it 
should return [{"name": "Chennai", "id": 1}]. 

How to fix this error ?


-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9ceeb485-7fea-4049-8c8c-fa6f453b5324%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Safe tag is working differently for different view.

2015-11-06 Thread sonu kumar
Yeah , I am sure both are using same template. I  am using same template on 
many pages. On all pages it's working fine. Only on one page question 
answer it's not working as expected. I couldn't find any solution till now.

On Thursday, November 5, 2015 at 8:48:05 PM UTC+5:30, Collin Anderson wrote:
>
> Hello,
>
> Are you sure they're using the same template? (If you change something 
> does it actually affect both views?)
>
> Is one of the views using mark_safe?
>
> Collin
>
> On Tuesday, October 27, 2015 at 9:29:02 PM UTC+1, sonu kumar wrote:
>>
>> I am having two views both are extending from same base.html and both of 
>> them have loaded same template tags, but one is escaping string using safe 
>> and other is not what could be 
>> Code 
>>
>> view 1
>>
>> {% extends 'base.html' %}
>> {% load inplace_edit mezzanine_tags rating_tags keyword_tags comment_tags 
>> nano_tags staticfiles %}
>>
>> ...
>>
>> {% comments_for object %}
>>
>> ...
>>
>> view 2
>>
>> {% extends "base.html" %}
>>
>> {% load inplace_edit mezzanine_tags comment_tags keyword_tags nano_tags i18n 
>> future staticfiles %}
>>
>> ...
>>
>> {% comments_for blog_post %}
>>
>> ...
>>
>>
>> view3 (comment.html)
>>
>> {% load i18n mezzanine_tags comment_tags  nano_tags future %}
>>
>> ...
>>
>> {{ comment.comment|safe  }}
>>
>> ...
>>
>>
>> As we can see both view 1 and 2 are using same function so it would be using 
>> same template but in view2 safe is working and in view1 it's not working.
>>
>>
>> What could be the reason for 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/fb56455d-c5cd-4ed8-88ce-127201d58ffb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error: The response content must be rendered before it can be accessed.

2015-11-04 Thread sonu kumar
I am having different URLs configuration. same view is called for two URLs 
based on **kwargs decision is made what to do? In one of case I need to get 
result of all related objects which is tagged with given keyword. I found 
another way to do achieve same using function based view.

On Thursday, November 5, 2015 at 2:44:22 AM UTC+5:30, Daniel Roseman wrote:
>
> On Wednesday, 4 November 2015 20:51:53 UTC, sonu kumar wrote:
>>
>> class based views are as below
>>
>> class TagList(TemplateView):
>>
>>  def get_context_data(self, **kwargs):
>>
>>  ...
>>
>>  qlist = QueList.as_view()(self.request, **kwargs)
>>  print qlist
>>
>>  ...
>> 
>>
>> class QueListView(ListView):
>> def get_context_data(self, **kwargs):
>>
>> ...
>>
>>
>> When QuesList.as_view() is called then it produces The response content must 
>> be rendered before it can be accessed . on *print qlist* line How to fix 
>> this error and what's reason behind this?
>>
>>
>
> Because a TemplateView returns a TemplateResponse, which needs to be 
> rendered. See the docs: 
> https://docs.djangoproject.com/en/1.8/ref/template-response/
>
> Can you explain why you are doing this? What's the point of calling one 
> view from another? There's almost certainly a better way to achieve what 
> you want. 
> --
> DR.
>

-- 
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/58817820-3048-4245-816e-b96d203f763e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Error: The response content must be rendered before it can be accessed.

2015-11-04 Thread sonu kumar
class based views are as below

class TagList(TemplateView):

 def get_context_data(self, **kwargs):

 ...

 qlist = QueList.as_view()(self.request, **kwargs)
 print qlist

 ...


class QueListView(ListView):
def get_context_data(self, **kwargs):

...


When QuesList.as_view() is called then it produces The response content must be 
rendered before it can be accessed . on *print qlist* line How to fix this 
error and what's reason behind 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/0f9e1da1-7f2d-4b27-b6a0-091faa13914f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Safe tag is working differently for different view.

2015-10-27 Thread sonu kumar
I am having two views both are extending from same base.html and both of 
them have loaded same template tags, but one is escaping string using safe 
and other is not what could be 
Code 

view 1

{% extends 'base.html' %}
{% load inplace_edit mezzanine_tags rating_tags keyword_tags comment_tags 
nano_tags staticfiles %}

...

{% comments_for object %}

...

view 2

{% extends "base.html" %}

{% load inplace_edit mezzanine_tags comment_tags keyword_tags nano_tags i18n 
future staticfiles %}

...

{% comments_for blog_post %}

...


view3 (comment.html)

{% load i18n mezzanine_tags comment_tags  nano_tags future %}

...

{{ comment.comment|safe  }}

...


As we can see both view 1 and 2 are using same function so it would be using 
same template but in view2 safe is working and in view1 it's not working.


What could be the reason for 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/001c1a9d-ae7f-4992-86f3-e72046d5212d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Overriding template view function in Django app.

2015-10-08 Thread sonu kumar
I have installed third party app(Mezzanine) whose urls are configured to 
use their view functions not View Class. Source code from 
mezzanine.blog.urls

   urlpatterns = patterns("mezzanine.blog.views",16 

   url("^%stag/(?P.*)%s$" % _slashes, "blog_post_list",

21 

name="blog_post_list_tag"),

18 

 
... 44 

)

As we can see they have configured blog URLs to use mezzanine.blog.views. Here 
we have few functions which are being called by URL dispatcher.  one of them is 
below.

*   def* blog_post_list(request 
, tag 
=*None*, year 
=*None*, month 
=*None*, username 
=*None*,20 

   category 
=*None*, 
template="blog /blog_post_list.html 
",21 

   extra_context 
=*None*):22 

"""23 

Display a list of blog posts that are filtered by tag, year, month,24 

author or category. Custom templates are checked for using the name25 

``blog /blog_post_list_XXX.html 
`` where 
``XXX`` is either the26 

category slug or author's username if given.27 

"""

I would like to override this function so that it will call my function to 
update context dictionary  or pass some more arguments to default function 
blog_post_list (it's having an argument extra_context so we can use this as 
external context) 


How can I achieve this ?

 Please provide complete details like do we have to modify urlpatterns then 
what should be changed, if we have to change view then what should be change ?

-- 
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/47eabec2-fdb1-47a8-b9f8-8f158c29852f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.