You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
File "/home/sprite/src/py/django/lasttime/recadm/urls.py", line 3, in <module>
from . import views
File "/home/sprite/src/py/django/lasttime/recadm/views.py", line 5, in <module>
from .forms import UsageForm
File "/home/sprite/src/py/django/lasttime/recadm/forms.py", line 4, in <module>
class UsageForm(forms.Form):
File "/home/sprite/src/py/django/lasttime/recadm/forms.py", line 5, in UsageForm
sub = forms.ForeignKey('subadd.Substance', on_delete=models.CASCADE)
AttributeError: module 'django.forms' has no attribute 'ForeignKey'
No workee; having trouble finding a concise resource on what I should be looking at instead of ForeignKey here... It may well help things out a little bit to check into the validity of on_delete=models.CASCADE in forms.py, as well. Somehow I think that if it actually is necessary, it'll at least look a little different-- say an s/models/forms/, if nothing else...
This came about while trying to implement a solution for #8.
The text was updated successfully, but these errors were encountered:
Try making this a forms.ModelForm - see https://docs.djangoproject.com/en/2.1/topics/forms/modelforms/ - then you really don't need to specify much at all, except the model you are basing the form on, and anything custom you want to add. It looks like, from the docs, that a models.ForeignKey in the model becomes forms.ModelChoiceField which defaults to a select drop-down widget.
Alternately, you can make sub a ChoiceField or a ModelChoiceField. I'm less clear on how that would work, you'd have to do more heavy lifting yourself.
Okay, I've got the majority of the initial changes made, I think. Unfortunately, I'm running into the error with trying to use the model from a different app, within the same project, again; referencing it from the query and/or from imports in the same way, working previously in the form, prior to the ModelForm usage is no longer workee. :| Going to open a separate issue for that, though.
lasttime/recadm/forms.py
Line 5 in 57d311a
No workee; having trouble finding a concise resource on what I should be looking at instead of
ForeignKey
here... It may well help things out a little bit to check into the validity ofon_delete=models.CASCADE
in forms.py, as well. Somehow I think that if it actually is necessary, it'll at least look a little different-- say an s/models/forms/, if nothing else...This came about while trying to implement a solution for #8.
The text was updated successfully, but these errors were encountered: