aarav-tech / ems Goto Github PK
View Code? Open in Web Editor NEWEmployee Management System
Employee Management System
Traceback (most recent call last):
File "manage.py", line 15, in
execute_from_command_line(sys.argv)
File "/home/snj/.virtualenvs/ems/lib/python3.6/site-packages/django/core/management/init.py", line 371, in execute_from_command_line
utility.execute()
File "/home/snj/.virtualenvs/ems/lib/python3.6/site-packages/django/core/management/init.py", line 347, in execute
django.setup()
File "/home/snj/.virtualenvs/ems/lib/python3.6/site-packages/django/init.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/snj/.virtualenvs/ems/lib/python3.6/site-packages/django/apps/registry.py", line 89, in populate
app_config = AppConfig.create(entry)
File "/home/snj/.virtualenvs/ems/lib/python3.6/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/home/snj/.virtualenvs/ems/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "/home/snj/.virtualenvs/ems/lib/python3.6/site-packages/django_elasticsearch_dsl/init.py", line 3, in
from .documents import Document # noqa
File "/home/snj/.virtualenvs/ems/lib/python3.6/site-packages/django_elasticsearch_dsl/documents.py", line 7, in
from elasticsearch_dsl import Document as DSLDocument
ImportError: cannot import name 'Document'
Hi sir.... Can I display the questions as per user.... Am trying to ....because all questions are referring for all user can it be restricted by manager id
Your readme is too short which makes it difficult to understand your code.
Hi Hardik,
I am stuck at starting the gunicorn service using shell script you provided.
I am getting below error-
gunicorn: error: unrecognized arguments: ubuntu /home/ubuntu/ankit/ems/run/gunicorn.sock
Here are the script details-
#!/bin/bash
NAME="ems"
DJANGODIR=/home/ubuntu/ankit/ems-
SOCKFILE=/home/ubuntu/ankit/ems-/run/gunicorn.sock
USER=ubuntu
GROUP=ubuntu
NUM_WORKERS=3
DJANGO_SETTINGS_MODULE=ems.settings
DJANGO_WSGI_MODULE=ems.wsgi
echo "Starting $NAME as whoami
"
cd $DJANGODIR
source ../venv/bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH
RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR
exec /home/ubuntu/ankit/venv/bin/gunicorn ${DJANGO_WSGI_MODULE}:application
--name $NAME
--workers $NUM_WORKERS
--user = $USER --group=$GROUP
--bind = $SOCKFILE
--log-level=debug
--log-file=-
Hi,
can you suggest how to handle manytomany relationship
I have the following models
#this model can be associated with more than 1 post
class Category(models.Model):
title = models.CharField(max_length=255,unique=True, blank=False, null=False)
#this model can be associated with more than 1 category
class Post(models.Model):
# post title
title = models.CharField(max_length=255, null=False)
content = models.TextField(null = False, max_length=12000)
slug = models.CharField(max_length=255, null=False, unique=True)
categories = models.ManyToManyField(Category, related_name='categories')
Can you please advise how to write a serializer that posts new data.
class PostCategorySerializer(serializers.ModelSerializer):
class Meta:
model = Category
read_only_fields = ('id',)
exclude = ('title','created_by')
class PostSerializer(serializers.ModelSerializer):
created_by_id = serializers.PrimaryKeyRelatedField(
queryset=User.objects.all(), source='created_by', write_only=True, required=False)
categories = PostCategorySerializer(many=True)
class Meta:
model = Post
fields = ('title', 'content', 'slug', 'categories', 'created_by_id')
def create(self, validated_data):
#before saving the post remove the field categories to avoid errors
categories = validated_data.pop('categories')
post = Post.objects.create(**validated_data)
for cat in categories:
Category.objects.create(**cat, categories=post)
return post
When I make the api request the post is created in the database but the categories are not associated
curl -H "Authorization: Bearer HKAEKzMg278hjsMVYYPlCdq6OqFA21" -X POST -H 'Content-Type: application/json' -d '{"title":"My first post","content":"My first post", "slug":"my-first-post", "short_description":"my first post....", "categories":[{"id":2, "title":"Python"}], "created_by":"2", "created_by_id":"2"}' http://localhost:8000/api/v1/posts/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.