'module' object has no attribute 'form_for_model' - django

When I am using attribute
form_for_model
I am getting an error module object has not attribute form_for_model..
I created the project from this http://www.mikecantelon.com/?q=node/22
but I am getting the above can any body help me

The post you are referring to is fairly old (2007) and a few things have changed since then:
form_for_model is deprecated.
I'd say you are better off looking at the official tutorial to get started with django.
The current way for creating forms based on models is explained in this part of the docs:
http://docs.djangoproject.com/en/1.8/topics/forms/modelforms/

Related

Django: single related object descriptor is deprecated, how can i replace it?

I was following this guide, when I arrived to this line:
from django.db.models.fields.related import SingleRelatedObjectDescriptor
I realized that SingleRelatedObjectDescriptor Class has been removed (deprecated) from the module,
I searched about its deprecation in the documentation, I couldn't find anything helpful, how i can achieve its behaviour now? with what i can replace it?
It looks like it is mentioned in the django 1.9 release notes
The related model object descriptor classes in
django.db.models.fields.related (private API) are moved from the
related module to related_descriptors and renamed as follows:
ReverseSingleRelatedObjectDescriptor is ForwardManyToOneDescriptor
SingleRelatedObjectDescriptor is ReverseOneToOneDescriptor
ForeignRelatedObjectsDescriptor is ReverseManyToOneDescriptor
ManyRelatedObjectsDescriptor is ManyToManyDescriptor
So I would assume that you need to do:
from django.db.models.fields.related_descriptors import ReverseOneToOneDescriptor

Django 2.1 - 'WhereNode' object has no attribute 'output_field' error

I am trying to filter some annotations in a ViewSetlike so:
queryset = Confirmation.objects.values('prediction__specimen_id').annotate(
sample_id=F('target_prediction__specimen_id'),
num_selected=Count('selected', filter=Q(selected=True)),
num_validated=Count('validated', filter=Q(validated=True)),
num_has_standard=Count('has_standard', filter=Q(has_standard=True)))
However, I am getting the following error:
'WhereNode' object has no attribute 'output_field'
My syntax seems to be correct according to all guides. I am running Django 2.1. Any idea what's happening? Can I not do this in Django Rest Framework because of paging?
Looks like syntax was indeed the issue. My answer has been edited to include the correct code. Cheers!

django error: 'DatabaseOperations' object has no attribute 'geo_db_type'

I have a django project that uses google maps. I wanted to create a GIS application using GeoDjango and Google Maps following this tutorial but went through several issues.
Now I'm stuck, although I decided to remove everything but django still throwing this error regardless I removed all the details related to GIS:
AttributeError: 'DatabaseOperations' object has no attribute 'geo_db_type'
I mean there is nothing at all that relate my django project (in the code) to GIS?!
I feel like installing GIS/postgres must have messed up the django default database system.
Any suggestions?
I think I will solve this problem by myself. I found two similar questions here in this place and no one solved them or gave a clear answer.
See this:
GeoDjango error: 'DatabaseOperations' object has no attribute 'geo_db_type'
Which means no clear solution and gotta get around it myself.
This post is thus closed.

How do you make a django field reference to a python class?

I am working on a project to expand a testing suite that my company uses. One of this things that was asked of me was to link the website to our Github source for code so that the dev team could continue tracking the issues there instead of trying to look in two places. I was able to do this but the problem is that every time the a bug is reported an issue is opened.
I want to add a field to my Django model that tracks an Issue object (from the github3.py wrapper) that is sent to Github. I want to use this to check if an Issue has already been created in Github by that instance of the BugReport and if it has been created, edit the Issue instead of creating another issue in Github that is a duplicate. Does Django have a something that can handle this sort of reference?
I am using Django 1.3.1 and Python 2.7.1
EDIT
I was able to figure my specific problem out using esauro's suggestions. However, as mkoistinen said, If this problem came up in a program where the work-around was not as easy as this one was, should an object reference be created like I had originally asked about or is that bad practice? and if it is okay to make an object reference like that, how would you do it with the Django models?
I'm the creator of github3.py.
If you want to get the issue itself via a number, there are a couple different ways to do this. I'm not sure how you're interacting with the API but you can do:
import github3
i = githbu3.issue('repo_owner', 'repo_name', issue_number)
or
import github3
r = github3.repository('repo_owner', 'repo_name')
i = r.issue(issue_number)
or
import github3
g = github3.login(client_key='client_key', client_secret='client_secret')
i = g.issue('repo_owner', 'repo_name', issue_number)
# or
r = g.repository('repo_owner', 'repo_name')
i = r.issue(issue_number)
otherwise if you're looking for something that's in an issue without knowing the number:
import github3
r = github3.repository('repo_owner', 'repo_name')
for i in r.iter_issues():
if 'text to search for' in i.body_text:
i.edit('...')

Cannot save property group to product in django-lfs

I already create properties and add them to property group.Then I assign to my new product.But django show me
TypeError at /manage/update-product-properties/1
save() got an unexpected keyword argument 'using'
Yeah, as you point out in your comment to your OP, the problem went away by using a different version of Django. using is part of the machinery for multi-database support in Django 1.2