Hi , I am new to Django framework.
I have created a python/django based app which is running on pythonanywhere, I recently added a new form to this app, this particular form is causing problems.
I get "no such table" error message on submitting the form. http://investaide.pythonanywhere.com/co_fins.html no such table: app_co_fin_model
I am using sqlite3 database, the on looking at the database, I was able to see the table corresponding to "app_co_fin_model".
Another issue , I have noticed is that by other forms are not getting saved in the db. http://investaide.pythonanywhere.com/ http://investaide.pythonanywhere.com/coffee-can.html
Are running fine and provide the desired output, however the form data is not visible in the database.
I am not sure if the problems are interrelated but it would be good to know your views.
Just to be clear, these same files and setup are working well in my local environment .. all of the form data is visible in the db.sqlite3 database.
extract from settings.py ....
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME' : 'db.sqlite3', } }
extract from models.py...
class co_fin_model(models.Model): exchange = models.CharField(max_length=200) company = models.CharField(max_length=200) sdate = models.DateField() edate = models.DateField()
extract from forms.py ...
class co_financials_form(forms.ModelForm):
exchange = forms.ChoiceField(initial= ia_stat.def_exchange,label='Exchange', choices=exchange)
company = forms.ChoiceField(initial= ia_stat.def_stock, label='Stock', choices=stocks)
sdate = forms.DateField(initial=sdate,label='Start Date', widget=forms.DateInput(attrs={'type': 'date'}))
edate = forms.DateField(initial=edate,label='End Date',widget=forms.DateInput(attrs={'type': 'date'}))
class Meta:
model = co_fin_model
fields = ["exchange", "company", "sdate", "edate"]
extract from views.py ...
@login_required(login_url="/login/") def cofin(request):
tbl_div_fin = "<div><h6 style=\"text-align:center; color:yellow;\"> </h6></div>"
tbl_div_fin2 = "<div><h6 style=\"text-align:center; color:yellow;\"> </h6></div>"
form = co_financials_form(request.POST or None)
message = "Please provide details"
msg2 = ""
msg_list = ""
print("%%%%", "Here1")
#html_template = loader.get_template( 'index.html' )
if form.is_valid():
d1 = form.cleaned_data
#print("######",d1)
print("%%%%", "Here2coffee")
exch = d1['exchange']
comp = d1['company']
sdate = d1['sdate']
edate = d1['edate']
form.save()
message = "Get financials of ..." + ia_sinfo.stock_name_code_map[comp][2] +" across market cycles"