-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/api #1
base: main
Are you sure you want to change the base?
Feature/api #1
Conversation
|
||
@admin.register(Place) | ||
class PlaceAdmin(OSMGeoAdmin): | ||
list_display = ('name', 'location', 'address', 'image', 'type') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list_display = ('name', 'location', 'address', 'image', 'type') | |
list_display = ('name', 'location', 'address', 'image', 'type', ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use black to evade '' and "" differences
|
||
@admin.register(Rate) | ||
class RateAdmin(admin.ModelAdmin): | ||
list_display = ("rating", "created_at", "user", "comment") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list_display = ("rating", "created_at", "user", "comment") | |
list_display = ("rating", "created_at", "user", "comment", ) |
|
||
@admin.register(Place) | ||
class PlaceAdmin(OSMGeoAdmin): | ||
list_display = ('name', 'location', 'address', 'image', 'type') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use black to evade '' and "" differences
name='type', | ||
field=models.CharField(default='shop', max_length=200), | ||
), | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Man, 12 migrations... There is squash
option
path("ping", views.ping, name="index"), | ||
path("places", PlaceListAPIView.as_view({"get": "list", "post": "create"}), name="place-list"), | ||
path("places/<int:pk>/ratings", PlaceListAPIView.as_view({"post": "create_rating"}), name="comment-list"), | ||
path("comments/<int:pk>/releted-comments", RelatedCommentAPIView.as_view({"post": "create_related_comment"}), name="related-comments") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path("comments/<int:pk>/releted-comments", RelatedCommentAPIView.as_view({"post": "create_related_comment"}), name="related-comments") | |
path("comments/<int:pk>/related-comments", RelatedCommentAPIView.as_view({"post": "create_related_comment"}), name="related-comments") |
|
||
|
||
def validate_rating(value): | ||
if value < 0 or value > 5: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if value < 0 or value > 5: | |
if not 0 <= value <= 5: |
|
||
from django.contrib.gis.geos import Point | ||
from entertainment.models import Place, Rate, Comment | ||
from entertainment.serializers import PlaceSerializer, RateSerializer, CommentSerializer | ||
|
||
|
||
@api_view(['GET']) | ||
def ping(request): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it relevant?
@@ -78,7 +81,7 @@ | |||
|
|||
DATABASES = { | |||
'default': { | |||
'ENGINE': 'django.db.backends.postgresql', | |||
'ENGINE': 'django.contrib.gis.db.backends.postgis', | |||
'NAME': os.environ['DATABASE'], | |||
'USER': "rating", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this not in env
vars?
class UserSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = User | ||
fields = ('username',) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are many files without empty line at the end of file
|
||
# Create your views here. | ||
from .serializers import RegisterSerializer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use absolute import
('location', django.contrib.gis.db.models.fields.PointField(srid=4326)), | ||
('address', models.CharField(max_length=255)), | ||
('image', models.ImageField(blank=True, null=True, upload_to='')), | ||
('type', models.CharField(choices=[('cafe', 'Cafe'), ('restaurant', 'Restaurant'), ('sport', 'Sport'), ('tech', 'tech'), ('shop', 'Shop')], default='cafe', max_length=20)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why max_length = 20, if longest choice is restaraunt which is 10 characters?
No description provided.