Hi, thank you for responding. My issue was because there was an autogenerated database, and another that I had created. When I ran the local dev server, for some reason, it used the one I created. However on Heroku, ir was using the autogenerated database. Once I deleted the auto generated database, the problem went away.
Sincerely yours,
Joel G Mathew
On Tue, 18 Dec 2018 at 01:06, Ketan Varia <automationdba@gmail.com> wrote:
Hi Mathew,I am still learner of django but I had faced similar issue while deploying my code to heroku. I followed below steps.- local server installed postgres database and updated settings.py- taken local backup of databasepg_dump -U postgres --no-owner --no-acl -f <backup file path.sql>- Deploy your code to heroku- heroku run python manage.py migrate- heroku run python manage.py createsuperuser- restore dataheroku pg:psql --app <application name> < <backup file path.sql>Regards,Ketan--On Mon, Dec 17, 2018 at 12:48 AM Joel Mathew <joel@joel.su> wrote:--
0I just started using heroku today. I was testing a web application, and got different results on using django app from local development server and heroku. I had imported to the database by running the django development webserver. Since the postgredb uses the amazonaws url, I assumed that this data would be available to the production server on heroku.
From my local django webserver, the following search yields correct results:
from django.db.models import CharField from django.db.models.functions import Lower CharField.register_lookup(Lower, "lower") import logging logger = logging.getLogger('testlogger') logger.info('This is a simple log message') items_set = [] if request.method == 'POST': print(request.POST.get) form = CGHSMetaForm(request.POST) name = request.POST.get('name').lower() items_set = CGHSRates.objects.filter( name__lower__contains=name).order_by('name') print(items_set) logger.info(items_set) else: form = CGHSMetaForm() return render( request, 'app/cghs_search.html', { 'rnd_num': randomnumber(), 'form': form, 'items': items_set, })I get the following results:
Code Name Rate 1098 After Mastectomy (Reconstruction)Mammoplasty Rs 13800.0 364 Local mastectomy-simple Rs 14548.0 251 Mastoidectomy Rs 17193.0On heroku, however, I receive an empty result.
The database is the default heroku database, a postgre db, defined by the following settings in settings.py:
import dj_database_url DATABASES = {'default': dj_database_url.config(default='postgres://kpnbcpyqtxxjqu:2c86exffsdff0d789e7f3b29d70sfsfsffs7be197sffsfsffb233@ec2-53-22-46-10.compute-1.amazonaws.com:5432/dful1l3ra7nknn')}Why does the same database when accessed on different servers yield different results? What should I be checking?
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+unsubscribe@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/CAA%3Diw__mSiZvrTZTrraLB4jq-kiFvm7Qkr0B6D%2Bffa2w4J-rkg%40mail.gmail.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+unsubscribe@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/CAOyh6%3DLOgkE14V6Ey1P41P_B5mG9qi%2BF%2Bf%3DCnxa1q-8eXtsO%2Bg%40mail.gmail.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+unsubscribe@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/CAA%3Diw_-iq06eD0Wn4K03R1jc_-j9cm8F4O%2B-VDVaJYapJ5WooA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment