TEMPLATE_CONTEXT_PROCESSORS doesn't seem to be present in settings.py by default

2010-09-09 Thread Sandip Bhattacharya
Is this variable supposed to be present in default generation of
settings.py after a startproject? Because I don't see this variable in
any of the projects that I am creating.

The doc
(http://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATE_CONTEXT_PROCESSORS)
makes it seem as if this is pre-populated by default.

$ python -c 'import django;print django.VERSION'
(1, 2, 2, 'final', 0)

$ django-admin.py startproject testprocessor

$ grep TEMPLATE_CONTEXT_PROCESSORS testprocessor/settings.py

$


Thanks,
  Sandip

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



Re: TEMPLATE_CONTEXT_PROCESSORS doesn't seem to be present in settings.py by default

2010-09-09 Thread Sandip Bhattacharya
Never mind. Just saw http://code.djangoproject.com/ticket/6851

- Sandip

On Fri, Sep 10, 2010 at 3:51 AM, Sandip Bhattacharya
 wrote:
> Is this variable supposed to be present in default generation of
> settings.py after a startproject? Because I don't see this variable in
> any of the projects that I am creating.
>
> The doc
> (http://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATE_CONTEXT_PROCESSORS)
> makes it seem as if this is pre-populated by default.
>
>    $ python -c 'import django;print django.VERSION'
>    (1, 2, 2, 'final', 0)
>
>    $ django-admin.py startproject testprocessor
>
>    $ grep TEMPLATE_CONTEXT_PROCESSORS testprocessor/settings.py
>
>    $
>
>
> Thanks,
>  Sandip
>

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



Re: Creating A Model For Existing DB Table

2010-11-10 Thread Sandip Bhattacharya
On Wed, Nov 10, 2010 at 09:23:55AM -0800, octopusgrabbus wrote:
> # Create your models here.
> class ept_inv(models.Model):
> part_num = models.CharField(max_length=20)
> ept_type = models.SmallIntegerField
> inv_id = models.IntegerField
> load_date = models.DateField

Call the model classes. Dont return their references.


 class ept_inv(models.Model):
 part_num = models.CharField(max_length=20)
 ept_type = models.SmallIntegerField()
 inv_id = models.IntegerField()
 load_date = models.DateField()

- Sandip


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



Re: How to retrieve the latest object added (new one) in Django models and display it in the template?

2023-03-02 Thread Sandip Bhattacharya
Your problem is still about where the 'published’ value is coming from in the 
call to filter(published=published).

Is it coming from a form? A Get parameter? A post parameter? Extract it 
appropriately before calling filter()


> On Mar 2, 2023, at 3:46 AM, Byansi Samuel  wrote:
> 
> def action (request):
> latest_action=ActionGame.objects.filter(published=published). latest()


-- 
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/A09FDF66-9845-4B93-854D-8BBFC4F5A03D%40showmethesource.org.


Re: Django Guide

2023-03-05 Thread Sandip Bhattacharya
There is a good guide here as well: 
https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django


- Sandip

> On Mar 5, 2023, at 5:20 PM, Kennedy Saavedra  wrote:
> 
> Hello Abdullah, this is the documentation of 
> Django: https://docs.djangoproject.com/en/4.1/
> 
> Start from the basics
> 
> El dom, 5 mar 2023 a las 10:58, Abdullah Niaz ( >) escribió:
>> Hello, My Name is Abdullah. I am pursuing my computer science degree & I am 
>> in the second semester. I learned Python At my school. Now, I want to learn 
>> Django. Can Anyone guide me 
>> 
>> -- 
>> 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/ec131a61-b003-4979-bdb5-de5466bef6b2n%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/CAL-qgjfZ4MGpHOGMaAb%3Dcdw8UPE-RHRRs3Wu5na2TDA9k-Hg0g%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/4C318C9D-D1BF-4DCC-8533-C1F28ABE8C38%40showmethesource.org.


Re: static files

2023-03-12 Thread Sandip Bhattacharya
Static files outside apps are not served by default. Have you added the main 
directory static directory to settings yet?

https://docs.djangoproject.com/en/4.1/ref/settings/#std-setting-STATICFILES_DIRS

Something like this is typically done in project settings:

STATICFILES_DIRS = [BASE_DIR / "static"]

- Sandip

> On Mar 10, 2023, at 1:29 PM, Usra Saeed  wrote:
> 
> Hi,  I am uing django 3.2. My template and static folder are in the main 
> directory.  But my static files are not loading.
> I have one app. In this I have one template name "signin.html". I am using 
> {% extends "base.html" %}
> {% load static %}
> {% block content %}
>  Hello World 
> 
> {% endblock  %}
> 
> In main directory template folder I have base.html . 
> 
> 
> 
> 
> 
> -- 
> 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/759ee88b-13f6-457b-8abf-1212b30b6628n%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/7E012138-5A5A-41D2-A82F-E20D302C50B2%40showmethesource.org.


Re: Django Admin

2023-03-13 Thread Sandip Bhattacharya


> On Mar 13, 2023, at 5:14 AM, James Hunt  wrote:
> 
> I have yet to create a HTML page so I'm not sure that the inclusion of {% 
> csrf_token %} is required. I mean it's just the admin page I am trying to 
> access which is provided by Django and not a page created by me!!!
> 
> I am very surprised there is no fix for this issue!!! I might need to abandon 
> Django and move a different framework given that this issue is at the start 
> of a project!!!

There is clearly something else going on in your setup.

Here is a brand new Django project being created just now.

And the admin interface works without any issue.

https://gist.github.com/sandipb/cb9c9c6ba00603c30cf3a89d4141b2de

Can you check if you missed any steps?

Thanks,
  Sandip

-- 
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/AB3AE217-E571-4754-98EB-AF50C071A8B8%40showmethesource.org.


Re: Stuck with Django Tutorial Part 4

2023-03-14 Thread Sandip Bhattacharya
Can you share your urls.py?


> On Mar 14, 2023, at 1:33 AM, Nithin Kumar  wrote:
> 
> Hi,
> 
> Stuck with this problem 
> 
> https://docs.djangoproject.com/en/4.1/intro/tutorial04/
> 
> NoReverseMatch at /polls/2/Reverse for 'vote' with arguments '(2,)' not 
> found. 1 pattern(s) tried: ['polls/ 
> My detail.html is like this and it is failing at Line 1. 
> I checked all solutions online but no luck. 
> 
> 
> {% csrf_token %}
> 
> {{ question.question_text }}
> {% if error_message %}{{ error_message }}{% 
> endif %}
> {% for choice in question.choice_set.all %}
> 
> {{ choice.choice_text 
> }}
> {% endfor %}
> 
> 
> 
> 
> -- 
> 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/d6c40407-64a0-4418-ba9a-39db89b1c1dcn%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/A42F210A-ED92-49F6-A647-D57C4C6814B0%40showmethesource.org.


Re: sub-list not showing

2023-03-17 Thread Sandip Bhattacharya


> On Mar 16, 2023, at 2:22 PM, nef  wrote:
> 
> class Student(models.Model):
> #std_matricule = models.CharField(verbose_name='Student matricule', 
> max_length=6, null=False, unique=True, primary_key=True)
> std_matricule = models.CharField(verbose_name='Matricule', unique=True, 
> max_length=16, null=False, blank=False, help_text='Matricule of the student')
> std_parents = models.ForeignKey(Parents, on_delete=models.DO_NOTHING, 
> related_name='Parents', unique=False, null=True, blank=True, 
> verbose_name='Student parents')
> 

I believe that the “related_name” parameter to ForeignKey is the name of the 
set of THIS model(Student) in the foreign table(Parents). So it should be, 
“students”, not “Parents”.

Only then will a parent object refer to the set of students related to it by 
that name. e.g. parent.students.

This was a point of confusion for me when I read this the first time as well.

https://docs.djangoproject.com/en/4.1/topics/db/queries/#backwards-related-objects


Thanks,
  Sandip


-- 
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/181E8507-B83D-426D-B2AC-C61694D8FDC9%40showmethesource.org.


No downtime rolling upgrades with migration

2023-03-26 Thread Sandip Bhattacharya
New to django, so wanted to ask some questions that I didn’t find good 
resources for:

1. If you deploy django apps using docker, do you run migrations before 
launching gunicorn/uwsgi etc within the docker image?

2. If you do, how does rolling migrations work? Won’t the non-upgraded replicas 
start erroring if the new schema is not backward compatible?

3. How do you do non-backward compatible schema upgrades? Do you do it out of 
band from deployments? Do you shift traffic to a different cluster, and then 
zero traffic upgrade the whole cluster at once?

Thanks,
  Sandip

-- 
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/A9719D24-F6DA-45A6-A30A-EA8EA34754A1%40showmethesource.org.


Re: It is impossible to add a non-nullable field 'details1' to feature without specifying a default. This is because the database needs something to populate existing rows.

2023-03-26 Thread Sandip Bhattacharya
So what would you want for existing entries in the table which were added 
before you changed the model?

If you are ok with them being empty, you should use:
details = models.CharField(max_length=500, default=“”)

And run migrate again.

If you are ok instead of this column being null, then:
details = models.CharField(max_length=500, null=True, blank=True)

I don’t have a huge experience with migrations, so others can correct me if I 
am wrong, but intuitively I feel that defaults should be captured in code than 
doing one-off fixes manually while running migrations at the command line.

Thanks,
  Sandip


> On Mar 25, 2023, at 12:08 AM, Ebenezer Otchere  wrote:
> 
> Am new in django and have been getting errors in migrations, i need help
> when i try to do migrations it keeps telling me this
> it is impossible to add a non-nullable field 'details' to feature without 
> specifying a default. This is because the database needs something to 
> populate existing rows.
> Please select a fix:
>  1) Provide a one-off default now (will be set on all existing rows with a 
> null value for this column)
>  2) Quit and manually define a default value in models.py.
> Thank you  in advance
> from django.db import models
> 
> # Create your models here.
> 
> 
> class feature(models.Model) :
> 
> name = models.CharField(max_length=100)
> extra = models.CharField(max_length=100)
> details1 = models.CharField(max_length=500)
> 
> class art(models.Model):
> 
> name = models.CharField(max_length=100)
> details = models.CharField(max_length=500)
> 
> -- 
> 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/06f462e2-3e1d-4a1a-8a97-b183586e5663n%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/F716AB80-31C0-448A-9F09-3F1DEFE128E5%40showmethesource.org.


Re: No downtime rolling upgrades with migration

2023-03-26 Thread Sandip Bhattacharya


> On Mar 26, 2023, at 4:32 PM, Damanjeet Singh  wrote:
>> 3. How do you do non-backward compatible schema upgrades? Do you do it out 
>> of band from deployments? Do you shift traffic to a different cluster, and 
>> then zero traffic upgrade the whole cluster at once?
> 
> 
> Daman: Blue Green deployment can help. You can distribute traffic to old and 
> new. When all stable then move everything. You can use kubernetes with helm.



Do you do blue-green deployments with two different databases? 

- Sandip


-- 
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/66989169-7601-4CA1-A54B-B9B29F7B719B%40showmethesource.org.


Re: No downtime rolling upgrades with migration

2023-03-26 Thread Sandip Bhattacharya


> On Mar 26, 2023, at 6:47 PM, Damanjeet Singh  wrote:
> 
> Depending on the requirements. Either two different databases or point to one 
> database.
> 
> Or
> Link one database to master (read and write)
> 
> Another database instance to read only.
> 
> And you can change Another database to main.
> 

Thanks for your patience in answering my doubts. But I still have some follow 
up questions.

If it is the same database, and the migration changes the schema, won’t the 
older application code instances have the same problem with backward 
incompatible schema changes?

And if it is two databases, how does it work? If you set the older database to 
read-only, then traffic on the write path of the older application will break. 
If you somehow connect the two in sync, won’t the DDL changes on the primary 
replicate to the other replica as well, again causing the older application to 
break?

- Sandip

> 
> 
> On Sun, 26 Mar 2023, 22:33 Sandip Bhattacharya,  <mailto:sand...@showmethesource.org>> wrote:
>> 
>> 
>>> On Mar 26, 2023, at 4:32 PM, Damanjeet Singh >> <mailto:mailtoda...@gmail.com>> wrote:
>>>> 3. How do you do non-backward compatible schema upgrades? Do you do it out 
>>>> of band from deployments? Do you shift traffic to a different cluster, and 
>>>> then zero traffic upgrade the whole cluster at once?
>>> 
>>> 
>>> Daman: Blue Green deployment can help. You can distribute traffic to old 
>>> and new. When all stable then move everything. You can use kubernetes with 
>>> helm.
>> 
>> 
>> 
>> Do you do blue-green deployments with two different databases? 
>> 
>> - Sandip

-- 
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/CF4FC246-87DD-4F31-A7E7-D3B9682F7FC0%40showmethesource.org.