-1

I am trying to run the spyne Django soap server project on my computer but I can't run the project because the default port number which is 8000, is already in use so I want to change the port number of django soap server.

the related project

the related code:

    class Attributes(DjangoComplexModel.Attributes):
        django_model = FieldContainer
        django_exclude = ['excluded_field']


class HelloWorldService(Service):
    @rpc(Unicode, Integer, _returns=Iterable(Unicode))
    def say_hello(ctx, name, times):
        for i in range(times):
            yield 'Hello, %s' % name


class ContainerService(Service):
    @rpc(Integer, _returns=Container)
    def get_container(ctx, pk):
        try:
            return FieldContainer.objects.get(pk=pk)
        except FieldContainer.DoesNotExist:
            raise ResourceNotFoundError('Container')

    @rpc(Container, _returns=Container)
    def create_container(ctx, container):
        try:
            return FieldContainer.objects.create(**container.as_dict())
        except IntegrityError:
            raise ResourceAlreadyExistsError('Container')

class ExceptionHandlingService(DjangoService):

    """Service for testing exception handling."""

    @rpc(_returns=Container)
    def raise_does_not_exist(ctx):
        return FieldContainer.objects.get(pk=-1)

    @rpc(_returns=Container)
    def raise_validation_error(ctx):
        raise ValidationError(None, 'Invalid.')


app = Application([HelloWorldService, ContainerService,
                   ExceptionHandlingService],
    'spyne.examples.django',
    in_protocol=Soap11(validator='lxml'),
    out_protocol=Soap11(),
)

hello_world_service = csrf_exempt(DjangoApplication(app))
acun
  • 57
  • 4
  • Does this answer your question? [django change default runserver port](https://stackoverflow.com/questions/23639085/django-change-default-runserver-port) – Abdul Aziz Barkat Jul 04 '22 at 05:01

2 Answers2

0

When you run the django app specify the port like this python manage.py runserver 0.0.0.0:8080 to use 8080 instead of 8000

0

The easiest way out there is just type the required port to run after the "runserver" command so:

python manage.py runserver 7000
Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
ilyasbbu
  • 1,468
  • 4
  • 11
  • 22